@@ 54-68 (lines=15) @@ | ||
51 | $item->Comments()->getForeignClass()); |
|
52 | } |
|
53 | ||
54 | public function testAddNonComment() |
|
55 | { |
|
56 | $item = $this->objFromFixture('CommentableItem', 'first'); |
|
57 | $comments = $item->Comments(); |
|
58 | $this->assertEquals(4, $comments->count()); |
|
59 | $member = Member::get()->first(); |
|
60 | try { |
|
61 | $comments->add($member); |
|
62 | $this->fail('Should not have been able to add member to comments'); |
|
63 | } catch (InvalidArgumentException $e) { |
|
64 | $this->assertEquals( |
|
65 | 'CommentList::add() expecting a Comment object, or ID value', |
|
66 | $e->getMessage() |
|
67 | ); |
|
68 | } |
|
69 | } |
|
70 | ||
71 | public function testAddComment() |
|
@@ 124-143 (lines=20) @@ | ||
121 | $this->assertEquals(2, $item->Comments()->count()); |
|
122 | } |
|
123 | ||
124 | public function testRemoveNonComment() |
|
125 | { |
|
126 | $item = $this->objFromFixture('CommentableItem', 'first'); |
|
127 | $this->assertEquals(4, $item->Comments()->count()); |
|
128 | $comments = $item->Comments(); |
|
129 | ||
130 | // try and remove a non comment |
|
131 | $member = Member::get()->first(); |
|
132 | ||
133 | ||
134 | ||
135 | try { |
|
136 | $comments->remove($member); |
|
137 | $this->fail('Should not have been able to remove member from comments'); |
|
138 | } catch (InvalidArgumentException $e) { |
|
139 | $this->assertEquals( |
|
140 | 'CommentList::remove() expecting a Comment object, or ID', |
|
141 | $e->getMessage() |
|
142 | ); |
|
143 | } |
|
144 | } |
|
145 | } |
|
146 |