public function testCreate() { $country = CountryQuery::create()->filterByHasStates(1)->findOne(); $event = new StateCreateEvent(); $event->setVisible(1)->setCountry($country->getId())->setIsocode('AA')->setLocale('en_US')->setTitle('State1'); $action = new State(); $action->create($event); $createdState = $event->getState(); $this->assertInstanceOf('Thelia\\Model\\State', $createdState); $this->assertFalse($createdState->isNew()); $this->assertEquals($country->getId(), $createdState->getCountryId()); $this->assertEquals('AA', $createdState->getIsocode()); $this->assertEquals('en_US', $createdState->getLocale()); $this->assertEquals('State1', $createdState->getTitle()); return $createdState; }
public function create(StateCreateEvent $event) { $state = new StateModel(); $state->setVisible($event->isVisible())->setCountryId($event->getCountry())->setIsocode($event->getIsocode())->setLocale($event->getLocale())->setTitle($event->getTitle())->save(); $event->setState($state); }