/**
  * Loads expected data from test case annotations
  *
  * @see EcomDev_PHPUnit_Model_Test_LoadableInterface::loadByTestCase()
  */
 public function loadByTestCase(PHPUnit_Framework_TestCase $testCase)
 {
     $expectations = EcomDev_PHPUnit_Test_Case_Util::getAnnotationByNameFromClass(get_class($testCase), 'loadExpectation', array('class', 'method'), $testCase->getName(false));
     if (!$expectations) {
         $expectations[] = $testCase->getName(false);
     }
     $expectationData = array();
     foreach ($expectations as $expectation) {
         if (empty($expectation)) {
             $expectation = $testCase->getName(false);
         }
         $expectationFile = EcomDev_PHPUnit_Test_Case_Util::getYamlLoader(get_class($testCase))->resolveFilePath(get_class($testCase), EcomDev_PHPUnit_Model_Yaml_Loader::TYPE_EXPECTATION, $expectation);
         if (!$expectationFile) {
             $text = 'There was no expectation defined for current test case';
             if ($expectation) {
                 $text = sprintf('Cannot load expectation %s', $expectation);
             }
             throw new RuntimeException($text);
         }
         $expectationData = array_merge_recursive($expectationData, EcomDev_PHPUnit_Test_Case_Util::getYamlLoader()->load($expectationFile));
     }
     $this->_loadedData = new Varien_Object($expectationData);
     return $this;
 }
Exemple #2
0
 /**
  * Load YAML file
  *
  * @param string $filePath
  * @return EcomDev_PHPUnit_Model_Fixture
  * @throws InvalidArgumentException if file is not a valid YAML file
  */
 public function loadYaml($filePath)
 {
     $data = EcomDev_PHPUnit_Test_Case_Util::getYamlLoader()->load($filePath);
     if (empty($this->_fixture)) {
         $this->_fixture = $data;
     } else {
         $this->_fixture = array_merge_recursive($this->_fixture, $data);
     }
     return $this;
 }