aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/UsersShowTest.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:07:19 +0200
committerJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:19:12 +0200
commita3da1483a9e689846179159355badfec8073dbec (patch)
tree770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /tests/jsonapi/UsersShowTest.php
current code from svn, revision 62608
Diffstat (limited to 'tests/jsonapi/UsersShowTest.php')
-rw-r--r--tests/jsonapi/UsersShowTest.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/jsonapi/UsersShowTest.php b/tests/jsonapi/UsersShowTest.php
new file mode 100644
index 0000000..e0b154e
--- /dev/null
+++ b/tests/jsonapi/UsersShowTest.php
@@ -0,0 +1,47 @@
+<?php
+
+use JsonApi\Routes\Users\UsersShow;
+
+class UsersShowTest 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 testShouldShowUser()
+ {
+ $credentials = $this->tester->getCredentialsForTestAutor();
+ $dozent = $this->tester->getCredentialsForTestDozent();
+ $response = $this->getUser($credentials, $dozent['id']);
+ $this->tester->assertTrue($response->isSuccessfulDocument([200]));
+
+ $this->tester->assertSame($dozent['id'], $response->document()->primaryResource()->id());
+
+ $this->tester->storeJsonMd('get_own_user', $response);
+ }
+
+ // **** helper functions ****
+ private function getUser($credentials, $userId)
+ {
+ $app = $this->tester->createApp($credentials, 'get', '/users/{id}', UsersShow::class);
+
+ return $this->tester->sendMockRequest(
+ $app,
+ $this->tester->createRequestBuilder($credentials)
+ ->setUri('/users/'.$userId)
+ ->fetch()
+ ->getRequest()
+ );
+ }
+}