11 public $fixtures = array(
12 'comments' =>
'Comment'
15 public function testParentRelation()
17 $comment =
Comment::model()->findByPk($this->comments[
'child1'][
'id']);
18 $this->assertNotNull($comment->parent);
21 public function testChildRelation()
23 $comment =
Comment::model()->findByPk($this->comments[
'parent'][
'id']);
24 $this->assertCount(2, $comment->childs);
27 public function testIsParentScope()
29 $this->assertEquals(3,
Comment::model()->resetScope()->isParent()->countByAttributes(array(
'content_id' =>
'fixture1')));
32 public function testIsChildScope()
34 $this->assertEquals(2,
Comment::model()->resetScope()->isChild()->countByAttributes(array(
'content_id' =>
'fixture1')));
37 public function testDefaultScope()
39 $this->assertEquals(4,
Comment::model()->countByAttributes(array(
'content_id' =>
'fixture1')));
40 $this->assertEquals(5,
Comment::model()->resetScope()->countByAttributes(array(
'content_id' =>
'fixture1')));
43 public function testApprovedScope()
45 $this->assertEquals(1,
Comment::model()->approved()->countByAttributes(array(
'content_id' =>
'fixture1')));
48 public function testGetStatusText()
50 $this->assertEquals(
'Approved', $this->comments(
'approved')->getStatusText());
51 $this->assertEquals(
'Not approved', $this->comments(
'child2')->getStatusText());
53 $deleted =
Comment::model()->resetScope()->findByAttributes(array(
'status' => Comment::DELETED));
54 $this->assertEquals(
'Deleted', $deleted->getStatusText());
57 public function testDelete()
59 $this->comments(
'approved')->delete();
60 $this->assertNull(
Comment::model()->findByPk($this->comments(
'approved')->
id));
61 $this->assertNotNull(
Comment::model()->resetScope()->findByPk($this->comments(
'approved')->
id));
63 $this->comments(
'approved')->delete(
true);
64 $this->assertNull(
Comment::model()->resetScope()->findByPk($this->comments(
'approved')->
id));