spiffy / spiffy-test
PHPUnit bootstrapping module for ZF2
Installs: 36 252
Dependents: 9
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 3
Open Issues: 0
Requires
- php: >=5.3.3
- zendframework/zend-loader: ~2.2
- zendframework/zend-modulemanager: ~2.2
- zendframework/zend-mvc: ~2.2
- zendframework/zend-view: ~2.2
Requires (Dev)
- phpunit/phpunit: 3.*
This package is not auto-updated.
Last update: 2019-02-20 17:24:24 UTC
README
SpiffyTest is a module for bootstrapping PHPUnit and supplying you with a basic service manager instance.
Installation
Installation of SpiffyTest uses composer. For composer documentation, please refer to getcomposer.org.
php composer.phar require spiffy/spiffy-test:0.*
- Copy
spiffy-test/Bootstrap.php.dist
to yourtests/Bootstrap.php
. - Copy
spiffy-test/config/test.application.config.php.dist
to yourconfig/test.application.config.php
and modify themodules
key to include any test dependent modules. - Copy
spiffy-test/config/test.module.config.php.dist
to yourconfig/test.module.config.php.dist
if you have test specific module overrides (i.e., removing memcache in favor of array cache).
Installation without composer is not officially supported and requires you to setup autoloading on your own.
Usage
Using SpiffyTest involves setting up your testing bootstrap, module config, and application config (optional).
- copy
bootstrap.php.dist
to yourtest
directory and rename tobootstrap.php
. Setupphpunit.xml
to use this as your bootstrap file. - copy
module.config.php.dist
to yourtest
directory and rename tomodule.config.php
. Be sure to leaveSpiffyTest
in your list of modules! - if you have a custom application.config.php requirement then copy
application.config.php.dist
to yourtest
directory and rename toapplication.config.php
.
Once everything is setup you can access the Module singleton by using \SpiffyTest\Module::getInstance()
. This class
has helper methods availabe such as getApplication()
, getServiceManager()
and getApplicationConfig()
for testing a mvc stack. You can
reset everything by using the reset()
method.
Controllers
SpiffyTest comes with \SpiffyTest\Controller\AbstractHttpControllerTestCase
which is a customized controller test case
that uses SpiffyTest's application. To use, simply have your tests extend the class.