예제 #1
0
 /**
  * Retrieves fixture model singleton
  *
  * @param string|null $testCaseClass
  * @return EcomDev_PHPUnit_Model_Fixture
  * @throws RuntimeException
  */
 public static function getFixture($testCaseClass = null)
 {
     if ($testCaseClass !== null) {
         self::$fixtureModelAlias = self::getLoadableClassAlias($testCaseClass, 'fixture', self::XML_PATH_DEFAULT_FIXTURE_MODEL);
     } elseif (self::$fixtureModelAlias === null) {
         self::$fixtureModelAlias = self::getLoadableClassAlias(get_called_class(), 'fixture', self::XML_PATH_DEFAULT_FIXTURE_MODEL);
     }
     $fixture = Mage::getSingleton(self::$fixtureModelAlias);
     if (!$fixture instanceof EcomDev_PHPUnit_Model_FixtureInterface) {
         throw new RuntimeException('Fixture model should implement EcomDev_PHPUnit_Model_FixtureInterface interface');
     }
     $storage = Mage::registry(EcomDev_PHPUnit_Model_App::REGISTRY_PATH_SHARED_STORAGE);
     if (!$storage instanceof Varien_Object) {
         throw new RuntimeException('Fixture storage object was not initialized during test application setup');
     }
     $fixture->setStorage(Mage::registry(EcomDev_PHPUnit_Model_App::REGISTRY_PATH_SHARED_STORAGE));
     return $fixture;
 }