示例#1
0
 public function testCreateSale()
 {
     $event = new SaleCreateEvent();
     $event->setLocale('en_US')->setTitle('test create sale')->setSaleLabel('test create sale label');
     $saleAction = new Sale($this->getMockEventDispatcher());
     $saleAction->create($event);
     $createdSale = $event->getSale();
     $this->assertInstanceOf('Thelia\\Model\\Sale', $createdSale);
     $this->assertEquals('test create sale', $createdSale->getTitle());
     $this->assertEquals('test create sale label', $createdSale->getSaleLabel());
 }
示例#2
0
 /**
  * Create a new Sale
  *
  * @param SaleCreateEvent $event
  */
 public function create(SaleCreateEvent $event)
 {
     $sale = new SaleModel();
     $sale->setLocale($event->getLocale())->setTitle($event->getTitle())->setSaleLabel($event->getSaleLabel())->save();
     $event->setSale($sale);
 }
示例#3
0
 /**
  * Creates the creation event with the provided form data
  *
  * @param  array           $formData
  * @return SaleCreateEvent
  */
 protected function getCreationEvent($formData)
 {
     $saleCreateEvent = new SaleCreateEvent();
     $saleCreateEvent->setLocale($formData['locale'])->setTitle($formData['title'])->setSaleLabel($formData['label']);
     return $saleCreateEvent;
 }