spark plug
v0.6.3
Un package spécial qui renvoie une application basée sur Codeigniter 3 comme une seule variable. Peut être utile lors du test d'un projet Codeigniter 3 vers des cadres tels que phpunit.
Installez Spark Plug via le compositeur:
$ composer require rougin/spark-plugInstance $ ci = Rougin SparkPlug Instance:: create ();
// You can now use the CI_Controller instance
$ ci -> load -> helper ( ' inflector ' );Note
Au lieu de CI_Controller , il renvoie RouginSparkPlugController pour la handicap de type et ses bibliothèques.
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 ();Constantes disponibles qui peuvent être modifiées:
APPPATHVENDORVIEWPATH Note
Si vous définissez une nouvelle valeur APPPATH , la valeur de VIEWPATH sera définie sur APPPATH/views .
CI_Controller pour les tests unitaires 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 );
}
}Veuillez consulter Changelog pour plus d'informations ce qui a changé récemment.
$ composer test La licence MIT (MIT). Veuillez consulter la licence pour plus d'informations.