Exemplo n.º 1
0
 /**
  * Set the default fixtures directory for loading user fixtures
  * 
  * @param string $fixturesDirectory
  */
 public static function setFixturesDirectory($fixturesDirectory)
 {
     if (empty($fixturesDirectory)) {
         self::$fixturesDirectory = '';
     } else {
         self::$fixturesDirectory = rtrim($fixturesDirectory, '/\\') . '/';
     }
 }
 /**
  * Lazy object instantiation
  */
 protected function getInstance($class)
 {
     if (empty($this->objects[$class])) {
         if (!class_exists($class)) {
             PHPFIT_FixtureLoader::load('eg.' . $class, dirname(dirname(__FILE__)));
         }
         $this->objects[$class] = new $class();
     }
     return $this->objects[$class];
 }
 public function testLoadFixtureWithPathsSet()
 {
     try {
         $fixture = PHPFIT_FixtureLoader::load('SampleOnOnePath');
         $this->fail("Exception expected here");
     } catch (PHPFIT_Exception_LoadFixture $e) {
     }
     try {
         $fixture = PHPFIT_FixtureLoader::load('SampleOnAnotherPath');
         $this->fail("Exception expected here");
     } catch (PHPFIT_Exception_LoadFixture $e) {
     }
     PHPFIT_FixtureLoader::addFixturesDirectory(dirname(__FILE__) . '/fixtures/onePath');
     $fixture = PHPFIT_FixtureLoader::load('SampleOnOnePath');
     try {
         $fixture = PHPFIT_FixtureLoader::load('SampleOnAnotherPath');
         $this->fail("Exception expected here");
     } catch (PHPFIT_Exception_LoadFixture $e) {
     }
     PHPFIT_FixtureLoader::addFixturesDirectory(dirname(__FILE__) . '/fixtures/anotherPath');
     $fixture = PHPFIT_FixtureLoader::load('SampleOnOnePath');
     $fixture = PHPFIT_FixtureLoader::load('SampleOnAnotherPath');
 }
Exemplo n.º 4
0
 /**
  * load a fixture by java-stylish name (dot-sparated)
  *
  * @param string $fixtureName
  * @return PHPFIT_Fixture
  */
 public function loadFixture($fixtureName)
 {
     require_once 'FixtureLoader.php';
     return PHPFIT_FixtureLoader::load($fixtureName, $this->fixturesDirectory);
 }