コード例 #1
0
 public function setup()
 {
     $recipes = new Recipes();
     $recipes->loadFromJSON(file_get_contents(__DIR__ . '/recipes.json'));
     $items = new FridgeItems();
     $items->loadFromCSVFile(__DIR__ . '/fridge.csv');
     $this->fridge = new Fridge($items);
 }
コード例 #2
0
 public function testIterator()
 {
     /** @var Recipe $recipe */
     foreach ($this->recipes as $name => $recipe) {
         $this->assertEquals('Acme\\DemoBundle\\Model\\Recipe', get_class($recipe));
         $this->assertEquals($name, (string) $recipe);
     }
     /** @var Recipe $recipe */
     $recipe = $this->recipes->rewind();
     $this->assertEquals('grilled cheese on toast', (string) $recipe);
     $this->assertEquals('grilled cheese on toast', $this->recipes->key());
     $recipe = $this->recipes->next();
     $this->assertEquals('salad sandwich', (string) $recipe);
     $this->assertEquals('salad sandwich', $this->recipes->key());
     $recipe = $this->recipes->next();
     $this->assertEquals('vegemite sandwich', (string) $recipe);
     $this->assertEquals('vegemite sandwich', $this->recipes->key());
     $recipe = $this->recipes->next();
     $this->assertFalse($recipe);
     $recipe = $this->recipes->rewind();
     $this->assertEquals('grilled cheese on toast', (string) $recipe);
 }