-
Notifications
You must be signed in to change notification settings - Fork 708
/
ViewResponseListenerTest.php
46 lines (39 loc) · 1.38 KB
/
ViewResponseListenerTest.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
<?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;
class ViewResponseListenerTest extends WebTestCase
{
public static function tearDownAfterClass(): void
{
self::deleteTmpDir('ViewResponseListener');
parent::tearDownAfterClass();
}
public function testRedirect()
{
$client = $this->createClient(['test_case' => 'ViewResponseListener']);
$client->request(
'POST',
'/articles.json',
[],
[],
['CONTENT_TYPE' => 'application/json'],
'{"name": "Post 1", "body": "This is a blog post"}'
);
$this->assertSame(201, $client->getResponse()->getStatusCode());
$this->assertSame('http://localhost/hello/Post%201', $client->getResponse()->headers->get('location'));
$this->assertStringNotContainsString('fooo', $client->getResponse()->getContent());
}
public function testControllerReturnsView()
{
$client = $this->createClient(['test_case' => 'ViewResponseListener']);
$client->request('GET', '/articles.json');
$this->assertTrue($client->getResponse()->isSuccessful());
}
}