spark plug
v0.6.3
一個特殊的軟件包,將基於Codeigniter 3的應用程序作為單個變量返回。在測試Codeigniter 3項目以諸如Phpunit之類的框架時,可能很有用。
通過作曲家安裝Spark Plug :
$ composer require rougin/spark-plugInstance幫手 $ ci = Rougin SparkPlug Instance:: create ();
// You can now use the CI_Controller instance
$ ci -> load -> helper ( ' inflector ' );筆記
它不是CI_Controller ,而是返回RouginSparkPlugController用於構建其助手和庫。
SparkPlug插頭類 use Rougin SparkPlug SparkPlug ;
$ sparkplug = new SparkPlug ( $ GLOBALS , $ _SERVER );
$ ci = $ sparkplug -> instance ();
// The Inflector helper is now loaded ---
$ ci -> load -> helper ( ' inflector ' );
// -------------------------------------- use Rougin SparkPlug SparkPlug ;
$ sparkplug = new SparkPlug ( $ GLOBALS , $ _SERVER );
// Set the value of the APPPATH constant ---
$ sparkplug -> set ( ' APPPATH ' , ' /path/to/app ' );
// -----------------------------------------
$ ci = $ sparkplug -> instance ();可以修改的可用常數:
APPPATHVENDORVIEWPATH 筆記
如果設置新的APPPATH值,則VIEWPATH的值將設置為APPPATH/views 。
CI_Controller use Rougin SparkPlug Instance ;
class SampleTest extends PHPUnit_Framework_TestCase
{
public function testCodeigniterInstance ()
{
// Directory path to the test application
$ application = __DIR__ . ' /TestApp ' ;
// Instance::create($path, $_SERVER, $GLOBALS)
$ ci = Instance:: create ( $ application );
$ this -> assertInstanceOf ( ' CI_Controller ' , $ ci );
}
}有關更多信息,請參閱ChangElog最近發生了什麼變化。
$ composer test 麻省理工學院許可證(麻省理工學院)。請參閱許可證以獲取更多信息。