/** * Constructor. Save internally the reference to the passed fixture manager * * @param \Cake\TestSuite\Fixture\FixtureManager $manager The fixture manager */ public function __construct(FixtureManager $manager) { if (isset($_SERVER['argv'])) { $manager->setDebug(in_array('--debug', $_SERVER['argv'])); } $this->_fixtureManager = $manager; $this->_fixtureManager->shutdown(); }
/** * Chooses which fixtures to load for a given test * * @return void */ public function loadFixtures($fixtures) { if (func_num_args() > 1) { $fixtures = func_get_args(); } $this->testCase->fixtures = $fixtures; $this->fixtureManager->fixturize($this->testCase); $this->fixtureManager->load($this->testCase); }
/** * Chooses which fixtures to load for a given test * * @return void * @see \Cake\TestSuite\TestCase::$autoFixtures * @throws \Exception when no fixture manager is available. */ public function loadFixtures() { if (empty($this->fixtureManager)) { throw new \Exception('No fixture manager to load the test fixture'); } $args = func_get_args(); foreach ($args as $class) { $this->fixtureManager->loadSingle($class, null, $this->dropTables); } }
/** * Loads all fixtures from disk if none defined. * * @param \Cake\TestSuite\TestCase $test The test case to inspect. * @return void */ public function fixturize($test) { if (!isset($test->fixtures)) { $folder = new Folder($this->_fixturePath); $fixtureFiles = $folder->find('.*Fixture\\.php'); foreach ($fixtureFiles as $fixtureFile) { $fixtureName = str_replace('Fixture.php', '', $fixtureFile); $fixtureName = Inflector::underscore($fixtureName); $test->fixtures[] = 'app.' . $fixtureName; } } parent::fixturize($test); }
/** * Unloads fixtures from the test case. * * @param \PHPUnit_Framework_Test $test The test case * @param float $time current time * @return void */ public function endTest(PHPUnit_Framework_Test $test, $time) { if ($test instanceof TestCase) { $this->_fixtureManager->unload($test); } }