Lines Matching refs:h
32 $h = $this->helper();
33 $this->assertFalse($h->canAnnotate('', AUTH_READ), 'anonymous may not annotate');
34 $this->assertFalse($h->canAnnotate('alice', AUTH_NONE), 'no read access → no annotate');
35 $this->assertTrue($h->canAnnotate('alice', AUTH_READ), 'logged in + read → annotate');
36 $this->assertTrue($h->canAnnotate('alice', AUTH_EDIT), 'edit access implies read');
41 $h = $this->helper();
43 $this->assertTrue($h->canEditAnnotation($ann, 'alice', false), 'author may edit');
44 $this->assertFalse($h->canEditAnnotation($ann, 'bob', false), 'non-author may not edit');
45 $this->assertTrue($h->canEditAnnotation($ann, 'bob', true), 'admin may edit anyone');
46 $this->assertFalse($h->canEditAnnotation($ann, '', true), 'anonymous never edits');
51 $h = $this->helper();
53 $this->assertTrue($h->canEditReply($reply, 'alice', false));
54 $this->assertFalse($h->canEditReply($reply, 'bob', false));
55 $this->assertTrue($h->canEditReply($reply, 'bob', true));
60 $h = $this->helper();
61 $this->assertTrue($h->canClear(true));
62 $this->assertFalse($h->canClear(false));
71 $h = $this->helper();
74 $ann = $h->createAnnotation($id, ['exact' => 'hello world'], 'alice', 'A comment');
80 $this->assertCount(1, $h->getAnnotations($id));
81 $this->assertEquals($ann['id'], $h->getAnnotation($id, $ann['id'])['id']);
82 $this->assertEquals(['total' => 1, 'open' => 1, 'resolved' => 0], $h->getStats($id));
87 $h = $this->helper();
90 … $this->assertFalse($h->createAnnotation($id, ['exact' => 'x'], 'alice', ' '), 'empty body');
91 … $this->assertFalse($h->createAnnotation($id, ['exact' => ''], 'alice', 'body'), 'empty exact');
92 $this->assertFalse($h->createAnnotation($id, ['exact' => 'x'], '', 'body'), 'empty author');
93 $this->assertSame([], $h->getAnnotations($id), 'nothing was stored');
98 $h = $this->helper();
101 …$ann = $h->createAnnotation($id, ['exact' => str_repeat('q', 2000)], 'alice', str_repeat('x', 2000…
109 $h = $this->helper();
111 $ann = $h->createAnnotation($id, ['exact' => " foo\n\t bar "], 'alice', 'b');
117 $h = $this->helper();
119 $ann = $h->createAnnotation($id, ['exact' => 'foo'], 'alice', 'first');
121 $this->assertTrue($h->updateAnnotationBody($id, $ann['id'], 'second'));
122 $this->assertEquals('second', $h->getAnnotation($id, $ann['id'])['body']);
123 $this->assertFalse($h->updateAnnotationBody($id, 'nope', 'x'), 'missing id → false');
124 $this->assertFalse($h->updateAnnotationBody($id, $ann['id'], ' '), 'empty body → false');
126 $this->assertTrue($h->deleteAnnotation($id, $ann['id']));
127 $this->assertNull($h->getAnnotation($id, $ann['id']));
128 $this->assertFalse($h->deleteAnnotation($id, $ann['id']), 'already gone → false');
133 $h = $this->helper();
135 $ann = $h->createAnnotation($id, ['exact' => 'foo'], 'alice', 'b');
137 $this->assertTrue($h->setStatus($id, $ann['id'], 'resolved', 'bob'));
138 $resolved = $h->getAnnotation($id, $ann['id']);
143 $this->assertTrue($h->setStatus($id, $ann['id'], 'open', 'bob'));
144 $reopened = $h->getAnnotation($id, $ann['id']);
148 … $this->assertFalse($h->setStatus($id, $ann['id'], 'bogus', 'bob'), 'invalid status → false');
157 $h = $this->helper();
159 $ann = $h->createAnnotation($id, ['exact' => 'foo'], 'alice', 'b');
161 $reply = $h->addReply($id, $ann['id'], 'bob', 'a reply');
164 $this->assertCount(1, $h->getAnnotation($id, $ann['id'])['replies']);
166 $this->assertTrue($h->updateReply($id, $ann['id'], $reply['id'], 'edited reply'));
167 … $this->assertEquals('edited reply', $h->getAnnotation($id, $ann['id'])['replies'][0]['body']);
169 $this->assertTrue($h->deleteReply($id, $ann['id'], $reply['id']));
170 $this->assertCount(0, $h->getAnnotation($id, $ann['id'])['replies']);
172 …$this->assertFalse($h->addReply($id, 'missing-ann', 'bob', 'x'), 'reply to missing annotation → fa…
181 $h = $this->helper();
183 $keep = $h->createAnnotation($id, ['exact' => 'one'], 'alice', 'b1');
184 $drop = $h->createAnnotation($id, ['exact' => 'two'], 'alice', 'b2');
185 $h->setStatus($id, $drop['id'], 'resolved', 'alice');
187 $this->assertEquals(1, $h->clearResolved($id));
188 $remaining = $h->getAnnotations($id);
195 $h = $this->helper();
198 $h->createAnnotation($id, ['exact' => 'keep open'], 'alice', 'open');
199 $done = $h->createAnnotation($id, ['exact' => 'mark done'], 'alice', 'done');
200 $h->setStatus($id, $done['id'], 'resolved', 'alice');
207 $removed = $h->clearResolvedAll();
210 $remaining = $h->getAnnotations($id);
225 $h = $this->helper();
226 … $present = $h->createAnnotation($id, ['exact' => 'wiki page about cats'], 'alice', 'present');
227 $gone = $h->createAnnotation($id, ['exact' => 'text that is not here'], 'alice', 'gone');
231 }, $h->findOrphaned($id));
236 $this->assertEquals(1, $h->clearOrphaned($id), 'only the orphan is cleared');
237 $remaining = $h->getAnnotations($id);
248 $h = $this->helper();
249 $h->createAnnotation('anntest:listone', ['exact' => 'foo'], 'alice', 'b');
250 $h->createAnnotation('anntest:nested:listtwo', ['exact' => 'bar'], 'alice', 'b');
254 $gone = $h->createAnnotation('anntest:emptied', ['exact' => 'baz'], 'alice', 'b');
255 $h->deleteAnnotation('anntest:emptied', $gone['id']);
257 $pages = $h->getAnnotatedPages();
268 $h = $this->helper();
269 $h->createAnnotation($id, ['exact' => 'wiki page about cats'], 'alice', 'present');
270 $h->createAnnotation($id, ['exact' => 'text that is not here'], 'alice', 'gone');
274 $h->pageCounts($id)
283 $h = $this->helper();
285 … $present = $h->createAnnotation($id, ['exact' => 'wiki page about cats'], 'alice', 'present');
286 $h->setStatus($id, $present['id'], 'resolved', 'alice');
288 $gone = $h->createAnnotation($id, ['exact' => 'text that is not here'], 'alice', 'gone');
289 $h->setStatus($id, $gone['id'], 'resolved', 'alice');
293 $h->pageCounts($id)
299 $h = $this->helper();
302 $h->pageCounts('anntest:never')
308 $h = $this->helper();
312 $h->createAnnotation($id, ['exact' => 'wiki page about cats'], 'alice', 'present');
313 $h->createAnnotation($id, ['exact' => 'text that is not here'], 'alice', 'gone');
320 $removed = $h->clearOrphanedAll();
323 $remaining = $h->getAnnotations($id);
326 $this->assertSame(0, $h->pageCounts($id)['orphaned'], $id . ' has no orphans left');