Created
October 12, 2012 13:03
-
-
Save junichi11/3879106 to your computer and use it in GitHub Desktop.
CakePHPTestSuite for NetBeans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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