public function testCreateBrand() { $event = new BrandCreateEvent(); $event->setVisible(1)->setLocale('en_US')->setTitle('test create brand'); $brandAction = new Brand(); $brandAction->create($event, null, $this->getMockEventDispatcher()); $createdBrand = $event->getBrand(); $this->assertInstanceOf('Thelia\\Model\\Brand', $createdBrand); $this->assertEquals(1, $createdBrand->getVisible()); $this->assertEquals('test create brand', $createdBrand->getTitle()); }
/** * Creates the creation event with the provided form data * * @param array $formData * @return BrandCreateEvent */ protected function getCreationEvent($formData) { $brandCreateEvent = new BrandCreateEvent(); $brandCreateEvent->setLocale($formData['locale'])->setTitle($formData['title'])->setVisible($formData['visible']); return $brandCreateEvent; }
public function create(BrandCreateEvent $event) { $brand = new BrandModel(); $brand->setVisible($event->getVisible())->setLocale($event->getLocale())->setTitle($event->getTitle())->save(); $event->setBrand($brand); }