Exemplo n.º 1
0
 /**
  * @covers ::join
  */
 public function testJoinSoftDelete()
 {
     $repo = Tag::getRepo();
     $repo->getConfig()->setSoftDelete(true);
     $rel = new HasManyThrough('tags', Post::getRepo()->getConfig(), 'Harp\\Harp\\Test\\TestModel\\Tag', 'postTags');
     $select = new Select(Post::getRepo());
     $rel->join($select, 'Address');
     $this->assertEquals('SELECT `Post`.* FROM `Post` JOIN `PostTag` AS `postTags` ON `postTags`.`postId` = `Address`.`id` JOIN `Tag` AS `tags` ON `tags`.`id` = `postTags`.`tagId` AND `tags`.`deletedAt` IS NULL', $select->humanize());
 }
Exemplo n.º 2
0
 /**
  * @covers ::getRootRepo
  */
 public function testGetRootRepo()
 {
     $this->assertSame(Post::getRepo(), Post::getRepo()->getRootRepo());
     $this->assertSame(Post::getRepo(), BlogPost::getRepo()->getRootRepo());
 }
Exemplo n.º 3
0
 /**
  * @covers ::isModel
  */
 public function testIsModel()
 {
     $postConfig = Post::getRepo()->getConfig();
     $blogPostConfig = BlogPost::getRepo()->getConfig();
     $post = new Post();
     $blogPost = new BlogPost();
     $this->assertTrue($postConfig->isModel($post));
     $this->assertTrue($postConfig->isModel($blogPost));
     $this->assertTrue($blogPostConfig->isModel($post));
     $this->assertTrue($blogPostConfig->isModel($blogPost));
     $city = new City();
     $this->assertFalse($postConfig->isModel($city));
 }
Exemplo n.º 4
0
 /**
  * @covers ::loadCount
  */
 public function testLoadCount()
 {
     $find = $this->getMock('Harp\\Harp\\Find', ['applyFlags'], [Post::getRepo()]);
     $find->expects($this->once())->method('applyFlags')->with($this->equalTo(State::DELETED));
     $count = $find->loadCount(State::DELETED);
     $this->assertEquals(4, $count);
     $this->assertQueries(['SELECT COUNT(`Post`.`id`) AS `countAll` FROM `Post`']);
 }