rougin / spark-plug
Codeigniter applications as single variables.
Installs: 14 697
Dependents: 5
Suggesters: 2
Security: 0
Stars: 15
Watchers: 3
Forks: 5
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ~4.2|~5.7
- rougin/codeigniter: ~3.0
- scrutinizer/ocular: ~1.1.0
Suggests
- rougin/codeigniter: Packaged "system" folder of the Codeigniter framework.
- rougin/combustor: CRUD generator for the Codeigniter framework.
- rougin/credo: Doctrine ORM integration for the Codeigniter framework.
- rougin/ignite: Composer-based project for the Codeigniter framework.
- rougin/refinery: "Ready-to-eat" migrations for Codeigniter framework
- rougin/wildfire: Query Builder wrapper for the Codeigniter framework.
README
Spark Plug is a special PHP library that returns Codeigniter applications as single variables. This package might be useful when testing applications to frameworks such as PHPUnit.
Installation
Install Spark Plug
through Composer:
$ composer require rougin/spark-plug
Basic Usage
Using the Instance
helper
$ci = Rougin\SparkPlug\Instance::create(); // You can now use the CI_Controller instance $ci->load->helper('inflector');
Using the SparkPlug
class
use Rougin\SparkPlug\SparkPlug; $sparkplug = SparkPlug($GLOBALS, $_SERVER); $ci = $sparkplug->instance(); $ci->load->helper('inflector');
Modify constants to be defined
use Rougin\SparkPlug\SparkPlug; $sparkplug = SparkPlug($GLOBALS, $_SERVER); // Sets the value of the APPPATH constant $sparkplug->set('APPPATH', '/path/to/app'); $ci = $sparkplug->instance();
Available constants to be modified:
APPPATH
VENDOR
VIEWPATH
NOTE: If you set a new APPPATH
value, the value of VIEWPATH
will be set to APPPATH/views
.
Mock CI_Controller
for unit testing
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
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Credits
License
The MIT License (MIT). Please see LICENSE for more information.