1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aimeos\ShopBundle\Tests\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class JqadmControllerTest extends WebTestCase |
9
|
|
|
{ |
10
|
|
View Code Duplication |
public function testCopyAction() |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
$client = static::createClient(array(), array( |
13
|
|
|
'PHP_AUTH_USER' => 'admin', |
14
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
15
|
|
|
) ); |
16
|
|
|
|
17
|
|
|
$client->request( 'GET', '/unittest/jqadm/copy/product/0' ); |
18
|
|
|
$response = $client->getResponse(); |
19
|
|
|
|
20
|
|
|
$this->assertEquals( 200, $response->getStatusCode() ); |
21
|
|
|
$this->assertContains( '<div class="product-item', $response->getContent() ); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
|
25
|
|
View Code Duplication |
public function testCreateAction() |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
$client = static::createClient(array(), array( |
28
|
|
|
'PHP_AUTH_USER' => 'admin', |
29
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
30
|
|
|
) ); |
31
|
|
|
|
32
|
|
|
$client->request( 'GET', '/unittest/jqadm/create/product' ); |
33
|
|
|
$response = $client->getResponse(); |
34
|
|
|
|
35
|
|
|
$this->assertEquals( 200, $response->getStatusCode() ); |
36
|
|
|
$this->assertContains( '<div class="product-item', $response->getContent() ); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
View Code Duplication |
public function testDeleteAction() |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
$client = static::createClient(array(), array( |
43
|
|
|
'PHP_AUTH_USER' => 'admin', |
44
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
45
|
|
|
) ); |
46
|
|
|
|
47
|
|
|
$client->request( 'GET', '/unittest/jqadm/delete/product/0' ); |
48
|
|
|
$response = $client->getResponse(); |
49
|
|
|
|
50
|
|
|
$this->assertEquals( 200, $response->getStatusCode() ); |
51
|
|
|
$this->assertContains( '<table class="list-items', $response->getContent() ); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
|
View Code Duplication |
public function testGetAction() |
|
|
|
|
56
|
|
|
{ |
57
|
|
|
$client = static::createClient(array(), array( |
58
|
|
|
'PHP_AUTH_USER' => 'admin', |
59
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
60
|
|
|
) ); |
61
|
|
|
|
62
|
|
|
$client->request( 'GET', '/unittest/jqadm/get/product/0' ); |
63
|
|
|
$response = $client->getResponse(); |
64
|
|
|
|
65
|
|
|
$this->assertEquals( 200, $response->getStatusCode() ); |
66
|
|
|
$this->assertContains( '<div class="product-item', $response->getContent() ); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
View Code Duplication |
public function testSaveAction() |
|
|
|
|
71
|
|
|
{ |
72
|
|
|
$client = static::createClient(array(), array( |
73
|
|
|
'PHP_AUTH_USER' => 'admin', |
74
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
75
|
|
|
) ); |
76
|
|
|
|
77
|
|
|
$client->request( 'POST', '/unittest/jqadm/save/product/0' ); |
78
|
|
|
$response = $client->getResponse(); |
79
|
|
|
|
80
|
|
|
$this->assertEquals( 200, $response->getStatusCode() ); |
81
|
|
|
$this->assertContains( '<div class="product-item', $response->getContent() ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
View Code Duplication |
public function testSearchAction() |
|
|
|
|
86
|
|
|
{ |
87
|
|
|
$client = static::createClient(array(), array( |
88
|
|
|
'PHP_AUTH_USER' => 'admin', |
89
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
90
|
|
|
) ); |
91
|
|
|
|
92
|
|
|
$client->request( 'GET', '/unittest/jqadm/search/product' ); |
93
|
|
|
$response = $client->getResponse(); |
94
|
|
|
|
95
|
|
|
$this->assertEquals( 200, $response->getStatusCode() ); |
96
|
|
|
$this->assertContains( '<table class="list-items', $response->getContent() ); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
|
100
|
|
View Code Duplication |
public function testSearchActionSite() |
|
|
|
|
101
|
|
|
{ |
102
|
|
|
$client = static::createClient(array(), array( |
103
|
|
|
'PHP_AUTH_USER' => 'admin', |
104
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
105
|
|
|
) ); |
106
|
|
|
|
107
|
|
|
$client->request( 'GET', '/invalid/jqadm/search/product' ); |
108
|
|
|
$response = $client->getResponse(); |
109
|
|
|
|
110
|
|
|
$this->assertEquals( 200, $response->getStatusCode() ); |
111
|
|
|
$this->assertContains( '<table class="list-items', $response->getContent() ); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
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.