Esempio n. 1
0
/**
 * Chooses which fixtures to load for a given test
 *
 * @param string $fixture Each parameter is a model name that corresponds to a
 *                        fixture, i.e. 'Post', 'Author', etc.
 * @return void
 * @see CakeTestCase::$autoFixtures
 */
	public function loadFixtures() {
		if (empty($this->fixtureManager)) {
			throw new Exception(__d('cake_dev', 'No fixture manager to load the test fixture'));
		}
		$args = func_get_args();
		foreach ($args as $class) {
			$this->fixtureManager->loadSingle($class);
		}
	}
 protected function _loadFixtures($fixtures)
 {
     parent::_loadFixtures($fixtures);
     foreach ($fixtures as $fixture) {
         if (isset($this->_loaded[$fixture])) {
             continue;
         }
         if (preg_match('/^app\\.(\\w+)$/', $fixture, $m)) {
             $this->_generateFixture($fixture, $m[1]);
         }
     }
 }
Esempio n. 3
0
// features/support/hooks.php
App::uses('CakeTestCase', 'TestSuite');
class BddAllFixture extends CakeTestCase
{
    // (1)
    public $fixtures = ['app.post', 'plugin.users.user'];
}
$hooks->beforeSuite(function ($event) {
    // Do something before whole test suite
});
$hooks->afterSuite(function ($event) {
    // Do something after whole test suite
});
$hooks->beforeFeature('', function ($event) {
    // do something before each feature
});
$hooks->afterFeature('', function ($event) {
    // do something after each feature
});
$hooks->beforeScenario('', function ($event) {
    // (2)
    // do something before each scenario
    $manager = new CakeFixtureManager();
    $fixture = new BddAllFixture();
    $manager->fixturize($fixture);
    $manager->load($fixture);
});
$hooks->afterScenario('', function ($event) {
    // do something after each scenario
});
 /**
  * Not Implemented
  *
  * @param PHPUnit_Framework_Test $test
  * @param float $time
  * @return void
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof CakeTestCase) {
         $this->_fixtureManager->unload($test);
     }
 }