Exemplo n.º 1
0
 /**
  * @group Model
  */
 public function testPrepare()
 {
     /** @var TagModel $tagModel */
     $tagModel = TagModel::getInstance();
     $this->assertInstanceOf('Model\\TagModel', $tagModel);
     $this->assertInstanceOf('Model\\Cond\\TagCond', $tagModel->getCond());
     $tagModel->delete(TagCond::init()->where(array('id' => 1)));
     $tagData = array('id' => 1, 'name' => 'test prepare');
     $tagModel->import($tagData);
     $cond = TagCond::init()->with(TagCond::WITH_TAG_ALIAS);
     $tag = $tagModel->getById(1, $cond);
     $this->assertInstanceOf('Model\\Entity\\TagEntity', $tag);
     $this->assertEquals(1, $tag->getId());
 }
Exemplo n.º 2
0
 /**
  * Тестируем выборку с помощью WITH когда связть One To Many
  * @covers \Model\AbstractModel::__call
  */
 public function testWithFetchOnOneToManyLink()
 {
     $topicModel = TopicModel::getInstance();
     $tagModel = TagModel::getInstance();
     $topicModel->delete(array('id' => 8762));
     $topicData = array('id' => 8762, 'title' => 'one_to_many test', '_base_tag' => array('id' => 123, 'name' => 'testWithFetchOnOneToManyLink test inner'));
     $result = $topicModel->import($topicData);
     $cond = TopicCond::init()->with(TopicCond::WITH_BASE_TAG);
     $entity = $topicModel->getById(8762, $cond);
     $this->assertEquals(8762, $entity->getId());
     $this->assertEquals(123, $entity->getBaseTag()->getId());
     $tagData = array('id' => 9811, 'name' => 'one_to_one test', '_tag_info' => array('id' => 232, 'info' => 'test'));
     $tagModel->import($tagData);
     $cond = TagCond::init()->with(TagCond::WITH_TAG_INFO);
     $entity = $tagModel->getById(9811, $cond);
     $this->assertEquals(9811, $entity->getId());
     $this->assertEquals(232, $entity->getTagInfo()->getId());
 }