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\DoctrinePHPCRAdminBundle\Tests\WebTest\Admin; |
15
|
|
|
|
16
|
|
|
use Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\DataFixtures\Phpcr\LoadTreeData; |
17
|
|
|
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase; |
18
|
|
|
|
19
|
|
|
class ContentAdminTest extends BaseTestCase |
20
|
|
|
{ |
21
|
|
|
protected function setUp(): void |
22
|
|
|
{ |
23
|
|
|
$this->db('PHPCR')->loadFixtures([LoadTreeData::class]); |
24
|
|
|
$this->client = $this->createClient(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testContentList(): void |
28
|
|
|
{ |
29
|
|
|
$crawler = $this->client->request('GET', '/admin/fixtures/app/content/list'); |
30
|
|
|
$res = $this->client->getResponse(); |
31
|
|
|
|
32
|
|
|
$this->assertResponseSuccess($res); |
33
|
|
|
$this->assertCount(1, $crawler->filter('html:contains("Content 1")')); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testContentWithChildEdit(): void |
37
|
|
|
{ |
38
|
|
|
$crawler = $this->client->request('GET', '/admin/fixtures/app/content/test/content/content-1/edit'); |
39
|
|
|
$res = $this->client->getResponse(); |
40
|
|
|
|
41
|
|
|
$this->assertResponseSuccess($res); |
42
|
|
|
$this->assertCount(1, $crawler->filter('input[value="content-1"]')); |
43
|
|
|
$this->assertCount(1, $crawler->filter('input[value="Content 1"]')); |
44
|
|
|
$this->assertCount(1, $crawler->filter('input[value="/test/content"]')); |
45
|
|
|
$this->assertCount(1, $crawler->filter('input[value="/test/routes/route-1"]')); |
46
|
|
|
// ToDo: Sub Admin for child association |
47
|
|
|
$this->assertCount(1, $crawler->filter('div[id$="child"] select')); |
48
|
|
|
|
49
|
|
|
// see the routes selection of a ModelType |
50
|
|
|
$this->assertCount(1, $crawler->filter('div[id$="_routes"] select')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testContentWithChildrenEdit(): void |
54
|
|
|
{ |
55
|
|
|
$crawler = $this->client->request('GET', '/admin/fixtures/app/content/test/content/content-2/edit'); |
56
|
|
|
$res = $this->client->getResponse(); |
57
|
|
|
|
58
|
|
|
$this->assertResponseSuccess($res); |
59
|
|
|
$this->assertCount(1, $crawler->filter('input[value="content-2"]')); |
60
|
|
|
$this->assertCount(1, $crawler->filter('input[value="Content 2"]')); |
61
|
|
|
$this->assertCount(1, $crawler->filter('input[value="/test/content"]')); |
62
|
|
|
|
63
|
|
|
// see the children table view of a CollectionType |
64
|
|
|
$this->assertCount(1, $crawler->filter('div[id$="_children"] table')); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testContentCreate(): void |
68
|
|
|
{ |
69
|
|
|
$crawler = $this->client->request('GET', '/admin/fixtures/app/content/create'); |
70
|
|
|
$res = $this->client->getResponse(); |
71
|
|
|
$this->assertResponseSuccess($res); |
72
|
|
|
|
73
|
|
|
$button = $crawler->selectButton('Create'); |
74
|
|
|
$form = $button->form(); |
75
|
|
|
$node = $form->getFormNode(); |
76
|
|
|
$actionUrl = $node->getAttribute('action'); |
77
|
|
|
$uniqId = substr(strstr($actionUrl, '='), 1); |
78
|
|
|
|
79
|
|
|
$form[$uniqId.'[parentDocument]'] = '/test/content'; |
80
|
|
|
$form[$uniqId.'[name]'] = 'foo-test'; |
81
|
|
|
$form[$uniqId.'[title]'] = 'Foo Test'; |
82
|
|
|
|
83
|
|
|
$this->client->submit($form); |
|
|
|
|
84
|
|
|
$res = $this->client->getResponse(); |
85
|
|
|
|
86
|
|
|
// If we have a 302 redirect, then all is well |
87
|
|
|
$this->assertSame(302, $res->getStatusCode()); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function testShowContent(): void |
91
|
|
|
{ |
92
|
|
|
$crawler = $this->client->request('GET', '/admin/fixtures/app/content/test/content/content-1/show'); |
|
|
|
|
93
|
|
|
$res = $this->client->getResponse(); |
94
|
|
|
|
95
|
|
|
if (200 !== $res->getStatusCode()) { |
96
|
|
|
echo $res->getContent(); |
97
|
|
|
} |
98
|
|
|
$this->assertResponseSuccess($res); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
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: