Skip to content

Instantly share code, notes, and snippets.

@junichi11
Created October 12, 2012 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junichi11/3879106 to your computer and use it in GitHub Desktop.
Save junichi11/3879106 to your computer and use it in GitHub Desktop.
CakePHPTestSuite for NetBeans
<?php
class CakePHPControllerSuite extends CakeTestSuite {
public static function suite() {
$suite = new CakePHPControllerSuite('Cake Controller Test Sute');
$suite->addTestDirectory(TESTS . 'Case' . DS . 'Controller');
return $suite;
}
protected function setUp() {
parent::setUp();
// load CakePHP fixture
if (class_exists('CakeFixtureManager')) {
$this->fixtureManager = $this->_getFixtureManager();
}
foreach ($this->getIterator() as $test) {
if ($test instanceof CakeTestCase) {
$this->fixtureManager->fixturize($test);
$test->fixtureManager = $this->fixtureManager;
}
}
}
protected function tearDown() {
// shutdown CakePHP fixture
if (isset($this->fixtureManager)) {
$this->fixtureManager->shutdown();
}
parent::tearDown();
}
/**
* Get the fixture manager class specified or use the default one.
*
* @return instance of a fixture manager.
*/
protected function _getFixtureManager($arguments = array()) {
if (isset($arguments['fixtureManager'])) {
App::uses($arguments['fixtureManager'], 'TestSuite');
if (class_exists($arguments['fixtureManager'])) {
return new $arguments['fixtureManager'];
}
throw new RuntimeException(__d('cake_dev', 'Could not find fixture manager %s.', $arguments['fixtureManager']));
}
App::uses('AppFixtureManager', 'TestSuite');
if (class_exists('AppFixtureManager')) {
return new AppFixtureManager();
}
return new CakeFixtureManager();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment