-
Notifications
You must be signed in to change notification settings - Fork 708
/
RequestBodyParamConverterTest.php
56 lines (48 loc) · 1.92 KB
/
RequestBodyParamConverterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/*
* This file is part of the FOSRestBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\RestBundle\Tests\Functional;
use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController;
class RequestBodyParamConverterTest extends WebTestCase
{
public function testRequestBodyIsDeserialized()
{
$client = $this->createClient(['test_case' => 'RequestBodyParamConverter']);
$client->request(
'POST',
'/body-converter',
[],
[],
['CONTENT_TYPE' => 'application/json'],
'{"name": "Post 1", "body": "This is a blog post"}'
);
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertSame('Post 1', $client->getResponse()->getContent());
}
/**
* Added to the legacy group to not trigger a deprecation. This deprecation is triggered on version 4.4 of
* the TwigBundle where the PreviewErrorController class is deprecated. Since we only make sure not to break
* that controller class, we do not have to care about the deprecations.
*
* @group legacy
*
* @see https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1237
*/
public function testTwigErrorPage()
{
if (!class_exists(PreviewErrorController::class)) {
$this->markTestSkipped();
}
$client = $this->createClient(['test_case' => 'RequestBodyParamConverter']);
$client->request('GET', '/_error/404.txt');
// Status code 200 as this page describes an error but is not the result of an error.
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertContains('The server returned a "404 Not Found".', $client->getResponse()->getContent());
}
}