Exemplo n.º 1
0
 /**
  * @param $key
  *
  * @return mixed
  *
  * @throws \Stefanius\LaravelFixtures\Exception\FileNotFoundException
  */
 private function loadRelatedObjectData($key)
 {
     if (strpos($key, '@') === false) {
         return null;
     }
     $split = explode('@', $key);
     $loader = new Loader($this->formatTestApplicationPath('database/fixtures'));
     $data = $loader->loadYmlData($split[0]);
     return $data['items'][$split[1]];
 }
Exemplo n.º 2
0
 /**
  * @param string  $filename
  * @param integer $numberOfItems
  * @param array   $expectedLastItem
  *
  * @dataProvider providerTestFixtureData
  */
 public function testFixtureData($filename, $numberOfItems, $expectedLastItem)
 {
     $loader = new Loader($this->formatTestApplicationPath('database/fixtures'));
     $data = $loader->loadYmlData($filename);
     $this->assertArrayHasKey('settings', $data);
     $this->assertEquals(count($data['items']), $numberOfItems);
     $lastItem = array_pop($data['items']);
     unset($lastItem['pivot']);
     $this->assertEquals($lastItem, $expectedLastItem);
 }
Exemplo n.º 3
0
 /**
  * @param $key
  *
  * @return string
  *
  * @throws \Exception
  * @throws \Stefanius\LaravelFixtures\Exception\FileNotFoundException
  */
 protected function findRelation($key)
 {
     if (strpos($key, '@') === false) {
         throw new \Exception(sprintf("The key to the relation has to formed like 'ymlfile@itemkey', the value '%s' is incorrect.", $key));
     }
     $split = explode('@', $key);
     $data = $this->yamlLoader->loadYmlData($split[0]);
     return $data['items'][$split[1]];
 }