1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
<?php
require_once 'BlubberTestHelper.php';
class BlubberThreadsShowTest extends \Codeception\Test\Unit
{
use BlubberTestHelper;
/**
* @var \UnitTester
*/
protected $tester;
protected function _before()
{
\DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh);
// Create global template factory if neccessary
$has_template_factory = isset($GLOBALS['template_factory']);
if (!$has_template_factory) {
$GLOBALS['template_factory'] = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/templates');
}
}
protected function _after()
{
}
// tests
public function testShowPublicThread()
{
// given
$credentials = $this->tester->getCredentialsForTestAutor();
$thread = $this->createPublicBlubberThreadForUser($credentials, 'Who knows Daskylos?');
$response = $this->fetchThread($credentials, $thread);
$this->tester->assertTrue($response->isSuccessfulDocument([200]));
$document = $response->document();
$this->tester->assertTrue($document->isSingleResourceDocument());
$resourceObject = $document->primaryResource();
$this->tester->assertSame($thread->context_type, $resourceObject->attribute('context-type'));
$this->tester->assertSame($thread->content, $resourceObject->attribute('content'));
// check predicates
$this->tester->assertSame($thread->isCommentable($credentials['id']), $resourceObject->attribute('is-commentable'));
$this->tester->assertSame($thread->isReadable($credentials['id']), $resourceObject->attribute('is-readable'));
$this->tester->assertSame($thread->isWritable($credentials['id']), $resourceObject->attribute('is-writable'));
}
public function testShowCourseThread()
{
// given
$credentials = $this->tester->getCredentialsForTestAutor();
$courseId = 'a07535cf2f8a72df33c12ddfa4b53dde';
$thread = $this->createCourseBlubberThreadForUser($credentials, $courseId, 'I have seen Eribotes!');
$response = $this->fetchThread($credentials, $thread);
$this->tester->assertTrue($response->isSuccessfulDocument([200]));
$document = $response->document();
$this->tester->assertTrue($document->isSingleResourceDocument());
$resourceObject = $document->primaryResource();
$this->tester->assertSame($thread->context_type, $resourceObject->attribute('context-type'));
$this->tester->assertSame($thread->content, $resourceObject->attribute('content'));
// check predicates
$this->tester->assertSame($thread->isCommentable($credentials['id']), $resourceObject->attribute('is-commentable'));
$this->tester->assertSame($thread->isReadable($credentials['id']), $resourceObject->attribute('is-readable'));
$this->tester->assertSame($thread->isWritable($credentials['id']), $resourceObject->attribute('is-writable'));
}
}
|