Пример #1
0
 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);
 }
Пример #2
0
 /**
  * @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');
 }
Пример #3
0
 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);
 }
Пример #4
0
 /**
  * @return ARSet
  */
 public function getStates($loadReferencedRecords = array('State'))
 {
     return DeliveryZoneState::getRecordSetByZone($this, $loadReferencedRecords);
 }