1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Symfony-Util package. |
5
|
|
|
* |
6
|
|
|
* (c) Jean-Bernard Addor |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
13
|
|
|
|
14
|
|
|
class DefaultControllerTest extends WebTestCase |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
public function _testVersion() |
17
|
|
|
{ |
18
|
|
|
$this->assertSame( |
19
|
|
|
'3.4.16', |
20
|
|
|
Symfony\Component\HttpKernel\Kernel::VERSION |
21
|
|
|
); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
View Code Duplication |
public function testIndex() |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) { |
27
|
|
|
$this->markTestIncomplete(); |
28
|
|
|
} // Test does not work any more with Symfony 3.4 |
29
|
|
|
|
30
|
|
|
$client = static::createClient(); |
31
|
|
|
|
32
|
|
|
$crawler = $client->request('GET', '/'); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$this->assertSame( |
35
|
|
|
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK, |
36
|
|
|
$client->getResponse()->getStatusCode() |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
$this->assertContains('Hello World!', $client->getResponse()->getContent()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
View Code Duplication |
public function testArgument() |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) { |
45
|
|
|
$this->markTestIncomplete(); |
46
|
|
|
} // Test does not work any more with Symfony 3.4 |
47
|
|
|
|
48
|
|
|
$client = static::createClient(); |
49
|
|
|
|
50
|
|
|
$crawler = $client->request('GET', '/argument'); |
|
|
|
|
51
|
|
|
|
52
|
|
|
$this->assertSame( |
53
|
|
|
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK, |
54
|
|
|
$client->getResponse()->getStatusCode() |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$this->assertContains('Hello World!', $client->getResponse()->getContent()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
View Code Duplication |
public function testConstructor() |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) { |
63
|
|
|
$this->markTestIncomplete(); |
64
|
|
|
} // Test does not work any more with Symfony 3.4 |
65
|
|
|
|
66
|
|
|
$client = static::createClient(); |
67
|
|
|
|
68
|
|
|
$crawler = $client->request('GET', '/constructor'); |
|
|
|
|
69
|
|
|
|
70
|
|
|
$this->assertSame( |
71
|
|
|
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK, |
72
|
|
|
$client->getResponse()->getStatusCode() |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
$this->assertContains('Hello World!', $client->getResponse()->getContent()); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
View Code Duplication |
public function testVariadic() |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) { |
81
|
|
|
$this->markTestIncomplete(); |
82
|
|
|
} // Test does not work any more with Symfony 3.4 |
83
|
|
|
|
84
|
|
|
$client = static::createClient(); |
85
|
|
|
|
86
|
|
|
$crawler = $client->request('GET', '/variadic/request'); |
|
|
|
|
87
|
|
|
|
88
|
|
|
$this->assertSame( |
89
|
|
|
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK, |
90
|
|
|
$client->getResponse()->getStatusCode() |
91
|
|
|
); |
92
|
|
|
|
93
|
|
|
$this->assertContains('Hello World!', $client->getResponse()->getContent()); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.