public function update(StateUpdateEvent $event) { if (null !== ($state = StateQuery::create()->findPk($event->getStateId()))) { $state->setVisible($event->isVisible())->setCountryId($event->getCountry())->setIsocode($event->getIsocode())->setLocale($event->getLocale())->setTitle($event->getTitle())->save(); $event->setState($state); } }
/** * @param StateModel $state * @depends testCreate * @return StateModel */ public function testUpdate(StateModel $state) { $event = new StateUpdateEvent($state->getId()); $event->setIsocode('BB')->setVisible(0)->setCountry($state->getCountryId())->setLocale('en_US')->setTitle('State2'); $action = new State(); $action->update($event); $updatedState = $event->getState(); $this->assertInstanceOf('Thelia\\Model\\State', $updatedState); $this->assertEquals('BB', $updatedState->getIsocode()); $this->assertEquals(0, $updatedState->getVisible()); $this->assertEquals('en_US', $updatedState->getLocale()); $this->assertEquals('State2', $updatedState->getTitle()); return $updatedState; }