Beispiel #1
0
 protected function getUpdateEvent($formData)
 {
     $changeEvent = new CategoryUpdateEvent($formData['id']);
     // Create and dispatch the change event
     $changeEvent->setLocale($formData['locale'])->setTitle($formData['title'])->setChapo($formData['chapo'])->setDescription($formData['description'])->setPostscriptum($formData['postscriptum'])->setVisible($formData['visible'])->setParent($formData['parent'])->setDefaultTemplateId($formData['default_template_id']);
     return $changeEvent;
 }
Beispiel #2
0
 /**
  * @param CategoryModel $category
  * @depends testCreate
  */
 public function testUpdate(CategoryModel $category)
 {
     $event = new CategoryUpdateEvent($category->getId());
     $event->setLocale('en_US')->setTitle('bar')->setDescription('bar description')->setChapo('bar chapo')->setPostscriptum('bar postscriptum')->setVisible(0)->setParent(0)->setDispatcher($this->getDispatcher());
     $action = new Category();
     $action->update($event);
     $updatedCategory = $event->getCategory();
     $this->assertInstanceOf('Thelia\\Model\\Category', $updatedCategory);
     $this->assertEquals('en_US', $updatedCategory->getLocale());
     $this->assertEquals('bar', $updatedCategory->getTitle());
     $this->assertEquals('bar description', $updatedCategory->getDescription());
     $this->assertEquals('bar chapo', $updatedCategory->getChapo());
     $this->assertEquals('bar postscriptum', $updatedCategory->getPostscriptum());
     $this->assertEquals(0, $updatedCategory->getVisible());
     $this->assertEquals(0, $updatedCategory->getParent());
     return $updatedCategory;
 }
 /**
  * @param CategoryModel $category
  * @depends testCreate
  * @return CategoryModel
  */
 public function testUpdate(CategoryModel $category)
 {
     $template = new Template();
     $template->setName('A sample template')->save();
     $event = new CategoryUpdateEvent($category->getId());
     $event->setLocale('en_US')->setTitle('bar')->setDescription('bar description')->setChapo('bar chapo')->setPostscriptum('bar postscriptum')->setVisible(0)->setParent(0)->setDefaultTemplateId($template->getId());
     $action = new Category();
     $action->update($event, null, $this->getMockEventDispatcher());
     $updatedCategory = $event->getCategory();
     $this->assertInstanceOf('Thelia\\Model\\Category', $updatedCategory);
     $this->assertEquals('en_US', $updatedCategory->getLocale());
     $this->assertEquals('bar', $updatedCategory->getTitle());
     $this->assertEquals('bar description', $updatedCategory->getDescription());
     $this->assertEquals('bar chapo', $updatedCategory->getChapo());
     $this->assertEquals('bar postscriptum', $updatedCategory->getPostscriptum());
     $this->assertEquals(0, $updatedCategory->getVisible());
     $this->assertEquals($template->getId(), $updatedCategory->getDefaultTemplateId());
     $this->assertEquals(0, $updatedCategory->getParent());
     return [$updatedCategory, $template];
 }
Beispiel #4
0
 /**
  * @param array $data
  * @return \Symfony\Component\EventDispatcher\Event
  */
 protected function getUpdateEvent(array &$data)
 {
     $event = new CategoryUpdateEvent($data["id"]);
     $event->setLocale($data['locale'])->setParent($data['parent'])->setTitle($data['title'])->setVisible($data['visible'])->setChapo($data['chapo'])->setDescription($data['description'])->setPostscriptum($data['postscriptum']);
     $this->setLocaleIntoQuery($data["locale"]);
     return $event;
 }