aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/ActivityStreamShowTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/jsonapi/ActivityStreamShowTest.php')
-rw-r--r--tests/jsonapi/ActivityStreamShowTest.php76
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);
+ }
+ */
+}