2018-05-14 19:32:19 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
2019-11-28 08:16:50 +08:00
|
|
|
* For detailed copyright and license information, please view the
|
|
|
|
* LICENSE file that was distributed with this source code.
|
2018-05-14 19:32:19 +08:00
|
|
|
*/
|
|
|
|
|
2020-03-27 19:22:22 +08:00
|
|
|
namespace Flarum\Tests\integration\api\posts;
|
2018-05-14 19:32:19 +08:00
|
|
|
|
2019-01-31 04:15:27 +08:00
|
|
|
use Carbon\Carbon;
|
2020-03-27 19:22:22 +08:00
|
|
|
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
|
|
|
use Flarum\Tests\integration\TestCase;
|
2018-05-14 19:32:19 +08:00
|
|
|
|
2020-03-27 20:22:16 +08:00
|
|
|
class CreateTest extends TestCase
|
2018-05-14 19:32:19 +08:00
|
|
|
{
|
2020-03-27 19:22:22 +08:00
|
|
|
use RetrievesAuthorizedUsers;
|
2018-05-14 19:32:19 +08:00
|
|
|
|
2019-01-31 04:15:27 +08:00
|
|
|
public function setUp()
|
2018-05-14 19:32:19 +08:00
|
|
|
{
|
2019-01-31 04:15:27 +08:00
|
|
|
parent::setUp();
|
2018-05-14 19:32:19 +08:00
|
|
|
|
2019-01-31 04:15:27 +08:00
|
|
|
$this->prepareDatabase([
|
|
|
|
'discussions' => [
|
|
|
|
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2],
|
|
|
|
],
|
|
|
|
'posts' => [],
|
|
|
|
'users' => [
|
|
|
|
$this->normalUser(),
|
|
|
|
],
|
|
|
|
'groups' => [
|
|
|
|
$this->memberGroup(),
|
|
|
|
],
|
|
|
|
'group_user' => [
|
|
|
|
['user_id' => 2, 'group_id' => 3],
|
|
|
|
],
|
|
|
|
'group_permission' => [
|
|
|
|
['permission' => 'viewDiscussions', 'group_id' => 3],
|
|
|
|
]
|
|
|
|
]);
|
2018-05-14 19:32:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function can_create_reply()
|
|
|
|
{
|
2020-03-27 19:22:22 +08:00
|
|
|
$response = $this->send(
|
|
|
|
$this->request('POST', '/api/posts', [
|
|
|
|
'authenticatedAs' => 2,
|
|
|
|
'json' => [
|
|
|
|
'data' => [
|
|
|
|
'attributes' => [
|
|
|
|
'content' => 'reply with predetermined content for automated testing - too-obscure',
|
|
|
|
],
|
|
|
|
'relationships' => [
|
|
|
|
'discussion' => ['data' => ['id' => 1]],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
])
|
|
|
|
);
|
2018-05-14 19:32:19 +08:00
|
|
|
|
|
|
|
$this->assertEquals(201, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
}
|