aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi
diff options
context:
space:
mode:
authorElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2023-11-06 15:15:21 +0000
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2023-11-06 15:15:21 +0000
commit4b160476327ecb893c08ce4deb29ce1180f6e0ef (patch)
tree729dd07d746e78926566100a88ac01310222b76f /tests/jsonapi
parent279363bcfb5887658956a09519be04387c37155d (diff)
add implementation for /institutes/{id}/memberships route, fixes #3429
Closes #3429 Merge request studip/studip!2334
Diffstat (limited to 'tests/jsonapi')
-rw-r--r--tests/jsonapi/InstituteMembershipsIndexTest.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/jsonapi/InstituteMembershipsIndexTest.php b/tests/jsonapi/InstituteMembershipsIndexTest.php
new file mode 100644
index 0000000..f9ddf9d
--- /dev/null
+++ b/tests/jsonapi/InstituteMembershipsIndexTest.php
@@ -0,0 +1,41 @@
+<?php
+
+use JsonApi\Routes\Institutes\InstituteMembershipsIndex;
+
+class InstituteMembershipsIndexTest extends \Codeception\Test\Unit
+{
+ /**
+ * @var \UnitTester
+ */
+ protected $tester;
+
+ protected function _before()
+ {
+ \DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh);
+ }
+
+ protected function _after()
+ {
+ }
+
+ public function testIndexMemberships()
+ {
+ $credentials = $this->tester->getCredentialsForTestAutor();
+ $instituteId = '2560f7c7674942a7dce8eeb238e15d93';
+
+ $institute = \Institute::find($instituteId);
+
+ $app = $this->tester->createApp($credentials, 'get', '/institutes/{id}/memberships', InstituteMembershipsIndex::class);
+
+ $requestBuilder = $this->tester->createRequestBuilder($credentials);
+ $requestBuilder->setUri('/institutes/'.$instituteId.'/memberships')->fetch();
+
+ $response = $this->tester->sendMockRequest($app, $requestBuilder->getRequest());
+
+ $this->tester->assertTrue($response->isSuccessfulDocument([200]));
+ $document = $response->document();
+ $this->tester->assertTrue($document->isResourceCollectionDocument());
+ $resources = $document->primaryResources();
+ $this->tester->assertCount(count($institute->members), $resources);
+ }
+}