1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\NotificationBundle\Tests\Functional\Api; |
15
|
|
|
|
16
|
|
|
use Sonata\NotificationBundle\Entity\BaseMessage; |
17
|
|
|
use Sonata\NotificationBundle\Tests\App\AppKernel; |
18
|
|
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser; |
19
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
20
|
|
|
|
21
|
|
|
final class MessageControllerTest extends WebTestCase |
22
|
|
|
{ |
23
|
|
|
public function testPostMessageAction(): void |
24
|
|
|
{ |
25
|
|
|
$kernel = new AppKernel(); |
26
|
|
|
$kernel->boot(); |
27
|
|
|
|
28
|
|
|
$message = new BaseMessage(); |
29
|
|
|
$message->setBody(['Test']); |
30
|
|
|
|
31
|
|
|
$client = new KernelBrowser($kernel); |
32
|
|
|
$client->request('POST', '/api/notification/messages'); |
33
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode()); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testGetMessagesAction(): void |
37
|
|
|
{ |
38
|
|
|
$kernel = new AppKernel(); |
39
|
|
|
$kernel->boot(); |
40
|
|
|
|
41
|
|
|
$client = new KernelBrowser($kernel); |
42
|
|
|
$client->request('GET', '/api/notification/messages'); |
43
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode()); |
44
|
|
|
|
45
|
|
|
$client = new KernelBrowser($kernel); |
46
|
|
|
$client->request('GET', '/api/notification/messages.json'); |
47
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode()); |
48
|
|
|
|
49
|
|
|
$client->request('GET', '/api/notification/messages.xml'); |
50
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode()); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|