Ejemplo n.º 1
0
 public function testCreateNewDeliveryZoneZipMask()
 {
     $zipMask = DeliveryZoneZipMask::getNewInstance($this->zone, 'Viln%');
     $zipMask->save();
     $zipMask->reload();
     $this->assertEquals($zipMask->deliveryZone->get(), $this->zone);
     $this->assertEquals($zipMask->mask->get(), 'Viln%');
 }
Ejemplo n.º 2
0
 /**
  * @role update
  */
 public function saveZipMask()
 {
     if (($errors = $this->isValidMask()) === true) {
         $maskValue = $this->request->get('mask');
         if ($id = (int) $this->getId()) {
             $mask = DeliveryZoneZipMask::getInstanceByID($id);
             $mask->mask->set($maskValue);
         } else {
             $zone = DeliveryZone::getInstanceByID((int) $this->request->get('zoneID'));
             $mask = DeliveryZoneZipMask::getNewInstance($zone, $maskValue);
         }
         $mask->save();
         return new JSONResponse(array('ID' => $mask->getID()), 'success');
     } else {
         return new JSONResponse(false, 'failure', $this->translate('_could_not_save_mask'));
     }
 }
Ejemplo n.º 3
0
 public function testFindZoneWithMasks()
 {
     $zone1 = DeliveryZone::getNewInstance();
     $zone1->name->set('With ZIP');
     $zone1->isEnabled->set(true);
     $zone1->save();
     DeliveryZoneZipMask::getNewInstance($zone1, 'asd')->save();
     DeliveryZoneCountry::getNewInstance($zone1, 'LT')->save();
     $zone2 = DeliveryZone::getNewInstance();
     $zone2->name->set('Without ZIP');
     $zone2->isEnabled->set(true);
     $zone2->save();
     DeliveryZoneCountry::getNewInstance($zone2, 'LT')->save();
     $address = UserAddress::getNewInstance();
     $address->countryID->set('LT');
     $this->assertSame(DeliveryZone::getZoneByAddress($address), $zone2);
     $address->postalCode->set('asd');
     $this->assertSame(DeliveryZone::getZoneByAddress($address), $zone1);
 }