diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:07:19 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:19:12 +0200 |
| commit | a3da1483a9e689846179159355badfec8073dbec (patch) | |
| tree | 770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /tests/jsonapi/ActivityStreamShowTest.php | |
current code from svn, revision 62608
Diffstat (limited to 'tests/jsonapi/ActivityStreamShowTest.php')
| -rw-r--r-- | tests/jsonapi/ActivityStreamShowTest.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/jsonapi/ActivityStreamShowTest.php b/tests/jsonapi/ActivityStreamShowTest.php new file mode 100644 index 0000000..e841f97 --- /dev/null +++ b/tests/jsonapi/ActivityStreamShowTest.php @@ -0,0 +1,76 @@ +<?php + + +use JsonApi\Routes\ActivityStreamShow; + +class ActivityStreamShowTest extends \Codeception\Test\Unit +{ + /** + * @var \UnitTester + */ + protected $tester; + + protected function _before() + { + \DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh); + } + + protected function _after() + { + } + + // tests + public function testShowEmptyStream() + { + $credentials = $this->tester->getCredentialsForTestAutor(); + + $response = $this->getActivityStreamForUser($credentials); + $this->tester->assertTrue($response->isSuccessfulDocument([200])); + + $document = $response->document(); + $this->tester->assertTrue($document->isResourceCollectionDocument()); + $this->tester->assertEmpty($document->primaryResources()); + } + + /* + public function testShowNotEmptyStream() + { + $credentials = $this->tester->getCredentialsForTestAutor(); + $content = 'Eneios likes water'; + $this->createBlubberActivity($credentials, $content); + + $response = $this->getActivityStreamForUser($credentials); + $this->tester->assertTrue($response->isSuccessfulDocument([200])); + + $document = $response->document(); + $this->tester->assertTrue($document->isResourceCollectionDocument()); + + $resources = $document->primaryResources(); + $this->tester->assertNotEmpty($resources); + + $resource = current($resources); + $this->assertContains($content, $resource->attribute('content')); + } + */ + + // **** helper functions **** + private function getActivityStreamForUser($credentials) + { + $app = $this->tester->createApp($credentials, 'get', '/users/{id}/activitystream', ActivityStreamShow::class); + + $requestBuilder = $this->tester->createRequestBuilder($credentials); + $requestBuilder + ->setUri('/users/'.$credentials['id'].'/activitystream') + ->fetch(); + + return $this->tester->sendMockRequest($app, $requestBuilder->getRequest()); + } + + /* + private function createBlubberActivity($credentials, $content) + { + $posting = $this->createBlubberForUser($credentials, $content); + \Studip\Activity\BlubberProvider::postActivity('ignored', $posting, true); + } + */ +} |
