aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/UserNewsCreateTest.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/UserNewsCreateTest.php
current code from svn, revision 62608
Diffstat (limited to 'tests/jsonapi/UserNewsCreateTest.php')
-rw-r--r--tests/jsonapi/UserNewsCreateTest.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/jsonapi/UserNewsCreateTest.php b/tests/jsonapi/UserNewsCreateTest.php
new file mode 100644
index 0000000..0b90d0b
--- /dev/null
+++ b/tests/jsonapi/UserNewsCreateTest.php
@@ -0,0 +1,46 @@
+<?php
+
+use JsonApi\Routes\News\UserNewsCreate;
+
+class UserNewsCreateTest extends \Codeception\Test\Unit
+{
+ /**
+ * @var \UnitTester
+ */
+ protected $tester;
+
+ protected function _before()
+ {
+ \DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh);
+ }
+
+ protected function _after()
+ {
+ }
+
+ //testszenario:
+ public function testUsersCreateNews()
+ {
+ $title = 'Fakenews';
+ $content = 'This is just fake news.';
+ $date = time();
+ $expire = $date + 1 * 7 * 24 * 60 * 60;
+ $credentials = $this->tester->getCredentialsForRoot();
+ $userId = $credentials['id'];
+ $response = $this->createTestNews($credentials, $userId, $title, $content, $date, $expire);
+ }
+
+ //helpers:
+ private function createTestNews($credentials, $userId, $title, $content, $date, $expire)
+ {
+ $app = $this->tester->createApp($credentials, 'post', '/users/{id}/news', UserNewsCreate::class);
+
+ return $this->tester->sendMockRequest(
+ $app,
+ $this->tester->createRequestBuilder($credentials)
+ ->setUri('/users/'.$userId.'/news')
+ ->fetch()
+ ->getRequest()
+ );
+ }
+}