Exemple #1
0
 /**
  * @group run
  */
 public function testGetMethodWhenOneFieldEntity()
 {
     TagModel::getInstance()->delete(array('name' => 'testGetMethodWhenOneFieldEntity'));
     $importResult = TagModel::getInstance()->import(array('name' => 'testGetMethodWhenOneFieldEntity', '_tag_alias' => array('name' => 'testGetMethodWhenOneFieldEntity_alias')));
     $tag = TagModel::getInstance()->getByName('testGetMethodWhenOneFieldEntity');
     $this->assertTrue($tag->exists());
     $tagAlias = TagAliasModel::getInstance()->getByTagAndName($tag, 'testGetMethodWhenOneFieldEntity_alias');
     $this->assertTrue($tagAlias->exists());
 }
Exemple #2
0
 /**
  * @group shl
  */
 public function testOneToOne()
 {
     $modelFirst = LinktestOtoFirstModel::getInstance();
     $this->assertInstanceOf('Model\\LinktestOtoFirstModel', $modelFirst);
     $modelSecond = LinktestOtoSecondModel::getInstance();
     $this->assertInstanceOf('Model\\LinktestOtoSecondModel', $modelSecond);
     $modelThird = LinktestOtoThirdModel::getInstance();
     $this->assertInstanceOf('Model\\LinktestOtoThirdModel', $modelThird);
     $cond = $modelSecond->getCond()->where(array('id' => 1));
     $modelSecond->delete($cond);
     $cond = $modelFirst->getCond()->where(array('id' => 2));
     $modelFirst->delete($cond);
     $cond = $modelThird->getCond()->where(array('id' => 4));
     $modelThird->delete($cond);
     $data = array('id' => 1, '_linktest_oto_first_alias' => array('id' => 3), '_linktest_oto_first' => array('id' => 2), '_third' => array('id' => 4));
     $modelSecond->import($data);
     $item = $modelSecond->getByLinktestOtoFirst(2);
     $this->assertEquals(1, $item->getId());
     $this->assertEquals(2, $item->getLinktestOtoFirstId());
     $this->assertEquals(3, $item->getLinktestOtoFirstAliasId());
     $this->assertEquals(4, $item->getThirdId());
     $item = $modelFirst->getByLinktestOtoSecond(1);
     $this->assertEquals(2, $item->getId());
     $item = $modelFirst->getByLinktestOtoSecond(1);
     $this->assertEquals(2, $item->getId());
     $tagAliasModel = TagAliasModel::getInstance();
     $tagAliasData = array('id' => 876, 'name' => 'one_to_many test', '_tag' => array('id' => 982, 'name' => 'one_to_many test inner'));
     $cond = TagAliasCond::init()->with(TagAliasCond::WITH_TAG);
     $tagAliasModel->import($tagAliasData);
     $entity = $tagAliasModel->getById(876, $cond);
     $this->assertEquals(876, $entity->getId());
 }