Exemplo n.º 1
0
 public function testSpecialUPCs()
 {
     $defaults = array('CouponCode', 'DatabarCoupon', 'HouseCoupon', 'MagicPLU', 'SpecialOrder');
     $all = AutoLoader::ListModules('SpecialUPC', False);
     foreach ($defaults as $d) {
         $this->assertContains($d, $all);
     }
     foreach ($all as $class) {
         $obj = new $class();
         $this->assertInstanceOf('SpecialUPC', $obj);
         $this->assertInternalType('boolean', $obj->is_special('silly nonsense input'));
     }
     $cc = new CouponCode();
     $this->assertEquals(True, $cc->is_special('0051234512345'));
     $this->assertEquals(True, $cc->is_special('0991234512345'));
     $this->assertEquals(False, $cc->is_special('0001234512345'));
     $dat = new DatabarCoupon();
     $this->assertEquals(True, $dat->is_special('811012345678901'));
     $this->assertEquals(False, $dat->is_special('8110123456790'));
     $this->assertEquals(False, $dat->is_special('0001234512345'));
     $hc = new HouseCoupon();
     $this->assertEquals(True, $hc->is_special('0049999900001'));
     $this->assertEquals(False, $hc->is_special('0001234512345'));
     $mp = new MagicPLU();
     $this->assertEquals(True, $mp->is_special('0000000008005'));
     $this->assertEquals(True, $mp->is_special('0000000008006'));
     $this->assertEquals(False, $mp->is_special('0001234512345'));
     $so = new SpecialOrder();
     $this->assertEquals(True, $so->is_special('0045400010001'));
     $this->assertEquals(False, $so->is_special('0001234512345'));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return SpeacialOrder the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = SpecialOrder::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }