aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2024-12-17 15:36:20 +0000
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2024-12-17 15:36:20 +0000
commit4b26a804f91f0b19651ab7104ff37b6c8b883150 (patch)
treec90a2723106168391c9924bfefff079c94061a99 /tests
parent515a80a6bba02be314c0e19795beeb40edf224df (diff)
add Blubber block for Courseware, fixes #726
Closes #726 Merge request studip/studip!3216
Diffstat (limited to 'tests')
-rw-r--r--tests/jsonapi/BlubberThreadsCreateTest.php40
1 files changed, 29 insertions, 11 deletions
diff --git a/tests/jsonapi/BlubberThreadsCreateTest.php b/tests/jsonapi/BlubberThreadsCreateTest.php
index d2bdaea..7cbdd14 100644
--- a/tests/jsonapi/BlubberThreadsCreateTest.php
+++ b/tests/jsonapi/BlubberThreadsCreateTest.php
@@ -36,7 +36,7 @@ class BlubberThreadsCreateTest extends \Codeception\Test\Unit
// given
$credentials = $this->tester->getCredentialsForTestAutor();
- $response = $this->createThread($credentials, 'private');
+ $response = $this->createThread($credentials, ['context-type' => 'private']);
$this->tester->assertTrue($response->isSuccessfulDocument([201]));
$document = $response->document();
@@ -70,30 +70,48 @@ class BlubberThreadsCreateTest extends \Codeception\Test\Unit
$this->tester->assertSame($credentials['id'], $links[0]['id']);
}
+ public function testCreateCourseThreadSucessfully()
+ {
+ // given
+ $credentials = $this->tester->getCredentialsForTestDozent();
+ $course_id = 'a07535cf2f8a72df33c12ddfa4b53dde';
+ $thread_title = 'Test-Thread';
+ $attributes = [
+ 'context-type' => 'course',
+ 'context-id' => $course_id,
+ 'content' => $thread_title
+ ];
+
+ $response = $this->createThread($credentials, $attributes);
+ $this->tester->assertTrue($response->isSuccessfulDocument([201]));
+
+ $document = $response->document();
+ $this->tester->assertTrue($document->isSingleResourceDocument());
+
+ $resourceObject = $document->primaryResource();
+
+ $this->tester->assertSame('course', $resourceObject->attribute('context-type'));
+ $this->tester->assertSame($thread_title, $resourceObject->attribute('content'));
+ }
+
public function testFailToCreateAnotherTypeOfThread()
{
// given
$credentials = $this->tester->getCredentialsForTestAutor();
- $response = $this->createThread($credentials, 'course');
- $this->tester->assertSame(400, $response->getStatusCode());
-
- $response = $this->createThread($credentials, 'institute');
+ $response = $this->createThread($credentials, ['context-type' => 'institute']);
$this->tester->assertSame(400, $response->getStatusCode());
- $response = $this->createThread($credentials, 'public');
+ $response = $this->createThread($credentials, ['context-type' => 'public']);
$this->tester->assertSame(400, $response->getStatusCode());
}
-
- private function createThread($credentials, $contextType = 'private')
+ private function createThread($credentials, $attributes)
{
$body = [
'data' => [
'type' => Schema::TYPE,
- 'attributes' => [
- 'context-type' => $contextType
- ]
+ 'attributes' => $attributes
]
];