public function testCreateNewDeliveryZoneState() { $deliveryState = DeliveryZoneState::getNewInstance($this->zone, $this->alaska); $deliveryState->save(); $deliveryState->reload(); $this->assertEquals($deliveryState->deliveryZone->get(), $this->zone); $this->assertTrue($deliveryState->state->get() === $this->alaska); }
/** * @role update */ public function saveStates() { $zone = DeliveryZone::getInstanceByID((int) $this->getId()); DeliveryZoneState::removeByZone($zone); foreach ((array) $this->request->get('active') as $activeStateID) { $state = State::getInstanceByID((int) $activeStateID); $deliveryZoneState = DeliveryZoneState::getNewInstance($zone, $state); $deliveryZoneState->save(); } return new JSONResponse(false, 'success'); }
public function testGetDeliveryZoneStates() { $zone = DeliveryZone::getNewInstance(); $zone->name->set(':TEST_ZONE'); $zone->save(); $deliveryState = DeliveryZoneState::getNewInstance($zone, State::getInstanceByID(1)); $deliveryState->save(); $states = $zone->getStates(); $this->assertEquals($states->getTotalRecordCount(), 1); $this->assertTrue($states->get(0) === $deliveryState); }
/** * @return ARSet */ public function getStates($loadReferencedRecords = array('State')) { return DeliveryZoneState::getRecordSetByZone($this, $loadReferencedRecords); }