Vulnero includes a tests directory containing a suite of PHPUnit unit tests which cover Vulnero's core functionality. Testing framework is in place to extend this coverage to your application as you start adding functionality. Writing new unit tests is as simple as exending the Vulnero_Test_PHPUnit_TestCase class. For example, if you create a new user-defined route /welcome, you can create a new test for it:
/* vim tests/application/controllers/WelcomeControllerTest.php */
<?php
class Controller_WelcomeControllerTest extends Vulnero_Test_PHPUnit_ControllerTestCase
{
public function testWelcome()
{
$this->dispatch('welcome');
$this->assertModule('default');
$this->assertController('welcome');
$this->assertAction('index');
}
}
Vulnero_Test_PHPUnit_ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase, so much of its documentation can be referenced as an additional resource. For convenience, a number of additional protected properties exist in the Vulnero_Test_PHPUnit_TestCase class to give you quick access to bootstrap resources:
<?php
public function testWelcome()
{
// bootstrap
$cache = $this->_bootstrap->bootstrap('cache')
->getResource('cache');
$this->assertTrue($cache instanceof Zend_Cache_Core);
// front controller
$this->assertTrue($this->_frontController->getParam('myParam'));
}
WordPress Simulation
It's important to note that WordPress is not loaded when executing your unit tests. This is acceptable because you're testing your application, not WordPress itself.
Vulnero accesses the WordPress API entirely through its Vulnero_WordPress class which serves as a broker to the global namespace functions. Vulnero_WordPress has a special mock mode that initializes itself when executed in command-line mode such as when running unit tests. This mode does not invoke the WordPress API; but instead simulates and records typical WordPress responses.
