1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\WebTest\Admin; |
4
|
|
|
|
5
|
|
|
use Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\DataFixtures\Phpcr\LoadTreeData; |
6
|
|
|
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase; |
7
|
|
|
|
8
|
|
|
class ContentAdminTest extends BaseTestCase |
9
|
|
|
{ |
10
|
|
|
public function setUp() |
11
|
|
|
{ |
12
|
|
|
$this->db('PHPCR')->loadFixtures(array(LoadTreeData::class)); |
13
|
|
|
$this->client = $this->createClient(); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function testContentList() |
17
|
|
|
{ |
18
|
|
|
$crawler = $this->client->request('GET', '/admin/tests/resources/content/list'); |
19
|
|
|
$res = $this->client->getResponse(); |
20
|
|
|
|
21
|
|
|
$this->assertResponseSuccess($res); |
22
|
|
|
$this->assertCount(1, $crawler->filter('html:contains("Content 1")')); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testContentWithChildEdit() |
26
|
|
|
{ |
27
|
|
|
$crawler = $this->client->request('GET', '/admin/tests/resources/content/test/content/content-1/edit'); |
28
|
|
|
$res = $this->client->getResponse(); |
29
|
|
|
|
30
|
|
|
$this->assertResponseSuccess($res); |
31
|
|
|
$this->assertCount(1, $crawler->filter('input[value="content-1"]')); |
32
|
|
|
$this->assertCount(1, $crawler->filter('input[value="Content 1"]')); |
33
|
|
|
$this->assertCount(1, $crawler->filter('input[value="/test/content"]')); |
34
|
|
|
$this->assertCount(1, $crawler->filter('input[value="/test/routes/route-1"]')); |
35
|
|
|
// ToDo: Sub Admin for child association |
36
|
|
|
$this->assertCount(1, $crawler->filter('input[value="/test/content/content-1/child"]')); |
37
|
|
|
|
38
|
|
|
// see the routes table |
39
|
|
|
$this->assertCount(1, $crawler->filter('div[id$="_routes"] table')); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testContentWithChildrenEdit() |
44
|
|
|
{ |
45
|
|
|
$crawler = $this->client->request('GET', '/admin/tests/resources/content/test/content/content-2/edit'); |
46
|
|
|
$res = $this->client->getResponse(); |
47
|
|
|
|
48
|
|
|
$this->assertResponseSuccess($res); |
49
|
|
|
$this->assertCount(1, $crawler->filter('input[value="content-2"]')); |
50
|
|
|
$this->assertCount(1, $crawler->filter('input[value="Content 2"]')); |
51
|
|
|
$this->assertCount(1, $crawler->filter('input[value="/test/content"]')); |
52
|
|
|
|
53
|
|
|
// see the routes table |
54
|
|
|
$this->assertCount(1, $crawler->filter('div[id$="_children"] table')); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testContentCreate() |
58
|
|
|
{ |
59
|
|
|
$crawler = $this->client->request('GET', '/admin/tests/resources/content/create'); |
60
|
|
|
$res = $this->client->getResponse(); |
61
|
|
|
$this->assertResponseSuccess($res); |
62
|
|
|
|
63
|
|
|
$button = $crawler->selectButton('Create'); |
64
|
|
|
$form = $button->form(); |
65
|
|
|
$node = $form->getFormNode(); |
66
|
|
|
$actionUrl = $node->getAttribute('action'); |
67
|
|
|
$uniqId = substr(strstr($actionUrl, '='), 1); |
68
|
|
|
|
69
|
|
|
$form[$uniqId.'[parentDocument]'] = '/test/content'; |
70
|
|
|
$form[$uniqId.'[name]'] = 'foo-test'; |
71
|
|
|
$form[$uniqId.'[title]'] = 'Foo Test'; |
72
|
|
|
|
73
|
|
|
$this->client->submit($form); |
|
|
|
|
74
|
|
|
$res = $this->client->getResponse(); |
75
|
|
|
|
76
|
|
|
// If we have a 302 redirect, then all is well |
77
|
|
|
$this->assertEquals(302, $res->getStatusCode()); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: