Beispiel #1
0
 public function load(ObjectManager $manager)
 {
     foreach (array('Margherita' => 7.9, 'Tomato Pie' => 8.5, 'Quattro Stagioni' => 7.9, 'Puttanesca' => 10.5, 'Roasted Pepper' => 9.9, 'New York-Style' => 9.9, 'Pepperoni-Mushroom' => 11.5, 'Sausage-Broccoli Rabe' => 7.9, 'Stuffed Crust' => 10.9, 'Meatball' => 9.9, 'Meat-Olive' => 11.5, 'Eggplant' => 7.9, 'Pepperoni' => 8.5, 'Herb' => 12.9, 'Fennel-Taleggio' => 12.9, 'Baked Ziti' => 10.9, 'Smoked Mozzarella' => 10.9, 'Squash-Pepper' => 9.9, 'Zucchini' => 10.5, 'Fig Squares' => 12.9, 'Cajun Shrimp' => 8.5, 'Clam' => 12.9, 'Bianco' => 12.9, 'Tomato Bianco' => 12.9, 'Bianco Mortadella' => 12.9, 'BBQ Chicken' => 7.9, 'Verde' => 9.9, 'Onion-Corn' => 10.5, 'Onion-Bacon' => 9.9, 'Onion-Ricotta' => 7.9, 'Apple-Cheddar' => 8.5, 'Bacon-Egg' => 10.9, 'Radicchio-Prosciutto' => 10.9, 'Pepper Lattice' => 12.9, 'Pissaladiere' => 11.5, 'Lamb-Feta' => 10.5, 'Ham-Brie' => 12.9, 'Wild Mushroom' => 7.9, 'Artichoke' => 9.9, 'Hawaiian' => 10.9, 'Fresh Veggie' => 8.5, 'Potato-Rosemary' => 9.9, 'Salad' => 11.5, 'Salmon-Potato' => 10.5, 'Chicago' => 10.9, 'Grape-Stuffed' => 8.5, 'Raisin-Stuffed' => 11.5, 'Banana-Chocolate' => 12.9) as $name => $price) {
         $pizza = new Pizza();
         $pizza->setName($name);
         $pizza->setPrice($price);
         $manager->persist($pizza);
     }
     $manager->flush();
 }
 /**
  * @dataProvider provider
  */
 public function testValidation(array $properties, array $errors)
 {
     $pizza = new Pizza();
     foreach ($properties as $property => $value) {
         $pizza->set($property, $value);
     }
     $violations = self::$validator->validate($pizza);
     /* @var $violations \Symfony\Component\Validator\ConstraintViolationList */
     $this->assertEquals(count($errors), count($violations), (string) $violations);
     foreach ($errors as $property => $message) {
         $pattern = sprintf('/\\.%s:\\s+%s$/m', $property, $message);
         $this->assertRegExp($pattern, (string) $violations, $violations);
     }
 }
Beispiel #3
0
 /**
  * @return float
  */
 public function getTotal()
 {
     return $this->pizza->getPrice() * $this->count;
 }