Пример #1
0
 public function testCreateNewDeliveryZoneCityMask()
 {
     $cityMask = DeliveryZoneCityMask::getNewInstance($this->zone, 'Viln%');
     $cityMask->save();
     $cityMask->reload();
     $this->assertEquals($cityMask->deliveryZone->get(), $this->zone);
     $this->assertEquals($cityMask->mask->get(), 'Viln%');
 }
Пример #2
0
 /**
  * @role update
  */
 public function saveCityMask()
 {
     if (($errors = $this->isValidMask()) === true) {
         $maskValue = $this->request->get('mask');
         if ($id = (int) $this->getId()) {
             $mask = DeliveryZoneCityMask::getInstanceByID($id);
             $mask->mask->set($maskValue);
         } else {
             $zone = DeliveryZone::getInstanceByID((int) $this->request->get('zoneID'));
             $mask = DeliveryZoneCityMask::getNewInstance($zone, $maskValue);
         }
         $mask->save();
         return new JSONResponse(array('ID' => $mask->getID()), 'success');
     } else {
         return new JSONResponse(array('errors' => $errors), 'failure', $this->translate('_could_not_save_mask'));
     }
 }
Пример #3
0
 public function testGetDeliveryZoneCityMasks()
 {
     $zone = DeliveryZone::getNewInstance();
     $zone->name->set(':TEST_ZONE');
     $zone->save();
     $mask = DeliveryZoneCityMask::getNewInstance($zone, 'asd');
     $mask->save();
     $masks = $zone->getCityMasks();
     $this->assertEquals($masks->getTotalRecordCount(), 1);
     $this->assertTrue($masks->get(0) === $mask);
 }