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
|
|
View Code Duplication |
public function testIndex() |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) { |
19
|
|
|
$this->markTestIncomplete(); |
20
|
|
|
} // Test does not work any more with Symfony 3.4 |
21
|
|
|
|
22
|
|
|
$client = static::createClient(); |
23
|
|
|
|
24
|
|
|
$crawler = $client->request('GET', '/'); |
|
|
|
|
25
|
|
|
|
26
|
|
|
$this->assertSame( |
27
|
|
|
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK, |
28
|
|
|
$client->getResponse()->getStatusCode() |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
$this->assertContains('Hello Component!', $client->getResponse()->getContent()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
View Code Duplication |
public function testArgument() |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) { |
37
|
|
|
$this->markTestIncomplete(); |
38
|
|
|
} // Test does not work any more with Symfony 3.4 |
39
|
|
|
|
40
|
|
|
$client = static::createClient(); |
41
|
|
|
|
42
|
|
|
$crawler = $client->request('GET', '/argument'); |
|
|
|
|
43
|
|
|
|
44
|
|
|
$this->assertSame( |
45
|
|
|
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK, |
46
|
|
|
$client->getResponse()->getStatusCode() |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
$this->assertContains('Hello Component!', $client->getResponse()->getContent()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
View Code Duplication |
public function testConstructor() |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) { |
55
|
|
|
$this->markTestIncomplete(); |
56
|
|
|
} // Test does not work any more with Symfony 3.4 |
57
|
|
|
|
58
|
|
|
$client = static::createClient(); |
59
|
|
|
|
60
|
|
|
$crawler = $client->request('GET', '/constructor'); |
|
|
|
|
61
|
|
|
|
62
|
|
|
$this->assertSame( |
63
|
|
|
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK, |
64
|
|
|
$client->getResponse()->getStatusCode() |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
$this->assertContains('Hello Component!', $client->getResponse()->getContent()); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.