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\AdminBundle\Tests\Functional\Controller; |
15
|
|
|
|
16
|
|
|
use Sonata\AdminBundle\Tests\App\AppKernel; |
17
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
18
|
|
|
use Symfony\Component\HttpFoundation\Request; |
19
|
|
|
use Symfony\Component\HttpFoundation\Response; |
20
|
|
|
|
21
|
|
|
final class CRUDControllerTest extends WebTestCase |
22
|
|
|
{ |
23
|
|
|
public function testList(): void |
24
|
|
|
{ |
25
|
|
|
$client = static::createClient(); |
26
|
|
|
$crawler = $client->request(Request::METHOD_GET, '/admin/tests/app/foo/list'); |
27
|
|
|
|
28
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
29
|
|
|
$this->assertSame( |
30
|
|
|
1, |
31
|
|
|
$crawler->filter('.sonata-ba-list-field:contains("foo_name")')->count() |
32
|
|
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testEmptyList(): void |
36
|
|
|
{ |
37
|
|
|
$client = static::createClient(); |
38
|
|
|
$client->request(Request::METHOD_GET, '/admin/empty/list'); |
39
|
|
|
|
40
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testCreate(): void |
44
|
|
|
{ |
45
|
|
|
$client = static::createClient(); |
46
|
|
|
$crawler = $client->request(Request::METHOD_GET, '/admin/tests/app/foo/create'); |
47
|
|
|
|
48
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
49
|
|
|
$this->assertSame( |
50
|
|
|
1, |
51
|
|
|
$crawler->filter('.sonata-ba-collapsed-fields label:contains("Name")')->count() |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testEmptyCreate(): void |
56
|
|
|
{ |
57
|
|
|
$client = static::createClient(); |
58
|
|
|
$client->request(Request::METHOD_GET, '/admin/empty/create'); |
59
|
|
|
|
60
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testShow(): void |
64
|
|
|
{ |
65
|
|
|
$client = static::createClient(); |
66
|
|
|
$crawler = $client->request(Request::METHOD_GET, '/admin/tests/app/foo/test_id/show'); |
67
|
|
|
|
68
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
69
|
|
|
$this->assertSame( |
70
|
|
|
1, |
71
|
|
|
$crawler->filter('td:contains("foo_name")')->count() |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testEmptyShow(): void |
76
|
|
|
{ |
77
|
|
|
$client = static::createClient(); |
78
|
|
|
$client->request(Request::METHOD_GET, '/admin/empty/test_id/show'); |
79
|
|
|
|
80
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function testEdit(): void |
84
|
|
|
{ |
85
|
|
|
$client = static::createClient(); |
86
|
|
|
$crawler = $client->request(Request::METHOD_GET, '/admin/tests/app/foo/test_id/edit'); |
87
|
|
|
|
88
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
89
|
|
|
$this->assertSame( |
90
|
|
|
1, |
91
|
|
|
$crawler->filter('.sonata-ba-collapsed-fields label:contains("Name")')->count() |
92
|
|
|
); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function testEmptyEdit(): void |
96
|
|
|
{ |
97
|
|
|
$client = static::createClient(); |
98
|
|
|
$client->request(Request::METHOD_GET, '/admin/empty/test_id/edit'); |
99
|
|
|
|
100
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
protected static function getKernelClass() |
104
|
|
|
{ |
105
|
|
|
return AppKernel::class; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|