This repository was archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathRESTContentControllerTest.php
More file actions
77 lines (69 loc) · 2.25 KB
/
RESTContentControllerTest.php
File metadata and controls
77 lines (69 loc) · 2.25 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2015 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Cmf\Bundle\ContentBundle\Tests\WebTest\Controller;
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
use Symfony\Component\HttpFoundation\Response;
/**
* @author Maximilian Berghoff <Maximilian.Berghoff@mayflower.de>
*/
class RESTContentControllerTest extends BaseTestCase
{
public function setUp()
{
$this->db('PHPCR')->loadFixtures(array(
'Symfony\Cmf\Bundle\ContentBundle\Tests\Resources\DataFixtures\Phpcr\LoadContentData',
));
$this->client = $this->createClient();
}
public function testGET()
{
$this->client->request('GET', '/content-1', array(), array(), array('ACCEPT'=> 'application/json'));
$res = $this->client->getResponse();
$this->assertEquals(200, $res->getStatusCode());
}
public function testPUT()
{
$this->client->request(
'PUT',
'/content-1',
array(),
array(),
array('ACCEPT'=> 'application/json', 'CONTENT_TYPE' => 'application/json'),
file_get_contents(__DIR__ . '/../../Resources/Fixtures/json/put.json')
);
$res = $this->client->getResponse();
$this->assertEquals(Response::HTTP_OK, $res->getStatusCode());
}
public function testDELETE()
{
$this->client->request(
'DELETE',
'/content-1',
array(),
array(),
array('ACCEPT'=> 'application/json')
);
$res = $this->client->getResponse();
$this->assertEquals(Response::HTTP_FOUND, $res->getStatusCode());
}
public function testPOST()
{
$this->client->request(
'POST',
'/collection',
array(),
array(),
array('ACCEPT'=> 'application/json', 'CONTENT_TYPE' => 'application/json'),
file_get_contents(__DIR__ . '/../../Resources/Fixtures/json/post.json')
);
$res = $this->client->getResponse();
$this->assertEquals(Response::HTTP_OK, $res->getStatusCode());
}
}