示例#1
0
文件: JoinTest.php 项目: meniam/model
 /**
  * @group Model
  * @group itrun
  */
 public function testJoin()
 {
     /**
      * @var TagModel
      */
     $productModel = ProductModel::getInstance();
     $this->assertInstanceOf('Model\\ProductModel', $productModel);
     $this->assertInstanceOf('Model\\Cond\\ProductCond', $productModel->getCond());
     /**
      * @var UserModel
      */
     $userModel = UserModel::getInstance();
     $this->assertInstanceOf('Model\\UserModel', $userModel);
     $this->assertInstanceOf('Model\\Cond\\UserCond', $userModel->getCond());
     $cond = $userModel->getCond()->where(array('email' => '*****@*****.**'));
     $userModel->delete($cond);
     /** @var UserEntity $data */
     $data = $userModel->getByEmail('*****@*****.**');
     $this->assertInstanceOf('Model\\Entity\\UserEntity', $data);
     $this->assertFalse($data->exists());
     $user = array('email' => '*****@*****.**', '_user_info' => array('about' => 'just a test'));
     $userModel->import($user);
     $data = $userModel->getByEmail('*****@*****.**');
     $this->assertInstanceOf('Model\\Entity\\UserEntity', $data);
     $this->assertTrue($data->exists());
     $cond = $userModel->getCond()->where(array('email' => '*****@*****.**'))->with(UserCond::WITH_USER_INFO);
     $user = $userModel->get($cond);
     $this->assertInstanceOf('Model\\Entity\\UserInfoEntity', $user->getUserInfo());
 }
示例#2
0
 private function getViewLink(\model\ProductModel $product)
 {
     return $this->navView->getViewProductLink(self::$ProductPosition . '=' . $product->GetID(), "Visa " . $product->getName()) . ' ';
 }
示例#3
0
 /**
  * @group Model
  */
 public function testGetIdsFromMixed()
 {
     $productModel = \Model\ProductModel::getInstance();
     $this->assertEquals(array(0 => 1), $productModel->getIdsFromMixed(1));
     $this->assertEquals(array(), $productModel->getIdsFromMixed(null));
 }
 public function addItem(\model\ProductModel $product)
 {
     $stmt = $this->database->prepare("INSERT INTO productBasket (productName, productPrice) VALUE (?,?)");
     $stmt->execute(array($product->getName(), $product->getPrice()));
     $product->setId($this->database->lastInsertId());
 }