Commit 1e5f120d authored by Nick Sellen's avatar Nick Sellen

Add API Forum emoji test

parent a6286d5a
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3563e50e601a905e795ebca148bebcd7",
"content-hash": "b4c06d100b67386d859f16559cd5cd30",
"packages": [
{
"name": "ddeboer/imap",
......@@ -973,6 +973,47 @@
],
"time": "2018-10-23T09:00:00+00:00"
},
{
"name": "flow/jsonpath",
"version": "0.4.0",
"source": {
"type": "git",
"url": "https://github.com/FlowCommunications/JSONPath.git",
"reference": "f0222818d5c938e4ab668ab2e2c079bd51a27112"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FlowCommunications/JSONPath/zipball/f0222818d5c938e4ab668ab2e2c079bd51a27112",
"reference": "f0222818d5c938e4ab668ab2e2c079bd51a27112",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"peekmo/jsonpath": "dev-master",
"phpunit/phpunit": "^4.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Flow\\JSONPath": "src/",
"Flow\\JSONPath\\Test": "tests/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Stephen Frank",
"email": "stephen@flowsa.com"
}
],
"description": "JSONPath implementation for parsing, searching and flattening arrays",
"time": "2018-03-04T16:39:47+00:00"
},
{
"name": "friendsofsymfony/rest-bundle",
"version": "2.5.0",
......
......@@ -2,18 +2,26 @@
class ForumApiCest
{
private $tester;
private $user;
private $region;
private $thread;
private $faker;
public function _before(\ApiTester $I)
{
$this->tester = $I;
$this->user = $I->createFoodsaver();
$this->region = $I->createRegion();
$I->addBezirkMember($this->region['id'], $this->user['id']);
$this->thread = $I->addForumTheme($this->region['id'], $this->user['id']);
$this->faker = Faker\Factory::create('de_DE');
}
/**
* @param ApiTester $I
*/
public function deleteNonExistingForumPostIs404(\ApiTester $I)
public function deleteNonExistingForumPostIs404(\ApiTester $I): void
{
$I->login($this->user['email']);
$I->sendDELETE('api/forum/post/9999999');
......@@ -24,7 +32,7 @@ class ForumApiCest
/**
* @param ApiTester $I
*/
public function deleteOwnPostSucceeds(\ApiTester $I)
public function deleteOwnPostSucceeds(\ApiTester $I): void
{
$I->login($this->user['email']);
$I->sendDELETE('api/forum/post/' . $this->thread['post']['id']);
......@@ -35,7 +43,7 @@ class ForumApiCest
/**
* @param ApiTester $I
*/
public function deleteForeignPostFails403(\ApiTester $I)
public function deleteForeignPostFails403(\ApiTester $I): void
{
$foreigner = $I->createFoodsaver();
$I->login($foreigner['email']);
......@@ -43,4 +51,26 @@ class ForumApiCest
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::FORBIDDEN);
$I->seeResponseIsJson();
}
/**
* @param ApiTester $I
* @throws Exception
*/
public function canUseEmojis(\ApiTester $I): void
{
$I->login($this->user['email']);
$body = 'I am so 😂 for you! ' . $this->faker->text(50);
$threadPath = 'api/forum/thread/' . $this->thread['id'];
$I->sendPOST($threadPath . '/posts', [
'body' => $body
]);
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::NO_CONTENT);
$I->seeInDatabase('fs_theme_post', ['body' => $body]);
$I->sendGET($threadPath);
$I->seeResponseIsJson();
$I->assertEquals(
'<p>' . $body . '</p>',
$I->grabDataFromResponseByJsonPath('$.data.posts[1].body')[0]
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment