Completed
Push — master ( 6114e5...8f259d )
by Aimeos
07:23
created

JqadmControllerTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 106
Duplicated Lines 85.85 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 2
dl 91
loc 106
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testCopyAction() 13 13 1
A testCreateAction() 13 13 1
A testDeleteAction() 13 13 1
A testGetAction() 13 13 1
A testSaveAction() 13 13 1
A testSearchAction() 13 13 1
A testSearchActionSite() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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