1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aimeos\ShopBundle\Tests\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class ExtadmControllerTest extends WebTestCase |
9
|
|
|
{ |
10
|
|
|
public function testIndex() |
11
|
|
|
{ |
12
|
|
|
$client = static::createClient(array(), array( |
13
|
|
|
'PHP_AUTH_USER' => 'admin', |
14
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
15
|
|
|
) ); |
16
|
|
|
$crawler = $client->request( 'GET', '/unittest/extadm/de/0' ); |
17
|
|
|
|
18
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
19
|
|
|
$this->assertEquals( 1, $crawler->filter( 'head:contains("/{site}/extadm/{lang}/{tab}")' )->count() ); |
20
|
|
|
$this->assertEquals( 1, $crawler->filter( 'body:contains("You need to enable javascript!")' )->count() ); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
public function testDo() |
25
|
|
|
{ |
26
|
|
|
$client = static::createClient(array(), array( |
27
|
|
|
'PHP_AUTH_USER' => 'admin', |
28
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
29
|
|
|
) ); |
30
|
|
|
|
31
|
|
|
$token = $client->getContainer()->get( 'security.csrf.token_manager' )->getToken( 'aimeos_admin_token' ); |
32
|
|
|
|
33
|
|
|
$client->request( 'POST', '/unittest/extadm/do?_token=' . $token->getValue(), |
34
|
|
|
array(), array(), array('CONTENT_TYPE' => 'application/json'), |
35
|
|
|
'[{"jsonrpc":"2.0","method":"Product_Type.searchItems","params":{"site":"unittest"},"id":2}]' |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
39
|
|
|
$this->assertStringStartsWith( '{', $client->getResponse()->getContent() ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
View Code Duplication |
public function testFile() |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
$client = static::createClient(array(), array( |
46
|
|
|
'PHP_AUTH_USER' => 'admin', |
47
|
|
|
'PHP_AUTH_PW' => 'adminpass', |
48
|
|
|
) ); |
49
|
|
|
|
50
|
|
|
$client->request( 'GET', '/unittest/extadm/file' ); |
51
|
|
|
|
52
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
53
|
|
|
$this->assertContains( 'EXTUTIL', $client->getResponse()->getContent() ); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
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.