spiffy / spiffy-test
PHPUnit bootstrapping module for ZF2
Installs: 37 150
Dependents: 9
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 3
Open Issues: 0
pkg:composer/spiffy/spiffy-test
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.distto yourtests/Bootstrap.php. - Copy
spiffy-test/config/test.application.config.php.distto yourconfig/test.application.config.phpand modify themoduleskey to include any test dependent modules. - Copy
spiffy-test/config/test.module.config.php.distto yourconfig/test.module.config.php.distif 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.distto yourtestdirectory and rename tobootstrap.php. Setupphpunit.xmlto use this as your bootstrap file. - copy
module.config.php.distto yourtestdirectory and rename tomodule.config.php. Be sure to leaveSpiffyTestin your list of modules! - if you have a custom application.config.php requirement then copy
application.config.php.distto yourtestdirectory 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.