Completed
Push — AUTOMATED_TESTING ( bddc1e...c0414d )
by Gordon
04:16
created

PageControllerTemplateOverrideExtensionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 54.9 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 3
lcom 1
cbo 2
dl 28
loc 51
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testLayoutTemplateOveride() 14 14 1
A testOuterTemplateOveride() 14 14 1
A testNoTemplateOverride() 0 12 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
class PageControllerTemplateOverrideExtensionTest extends FunctionalTest {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	protected static $fixture_file = 'template-override/tests/pages.yml';
6
7 View Code Duplication
	public function testLayoutTemplateOveride() {
1 ignored issue
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...
8
		$this->logInWithPermission('ADMIN');
9
		$page = $this->objFromFixture('Page', 'page1');
10
		$page->AlternativeTemplate = 'PageInnerTest';
11
		$page->write();
12
		$page->doPublish();
13
		$response = $this->get('/' . $page->URLSegment);
14
        $this->assertEquals(200, $response->getStatusCode());
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PageControllerTem...eOverrideExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
15
16
        // assert the the inner layout template has been used
17
        $this->assertExactMatchBySelector("div.marker", array(
18
		    "INNER LAYOUT"
19
		));
20
	}
21
22
23 View Code Duplication
	public function testOuterTemplateOveride() {
1 ignored issue
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...
24
		$this->logInWithPermission('ADMIN');
25
		$page = $this->objFromFixture('Page', 'page1');
26
		$page->AlternativeTemplate = 'PageOuterTest';
27
		$page->write();
28
		$page->doPublish();
29
		$response = $this->get('/' . $page->URLSegment);
30
        $this->assertEquals(200, $response->getStatusCode());
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PageControllerTem...eOverrideExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
32
        // show the the outer layout template has been used
33
        $this->assertExactMatchBySelector("div.marker", array(
34
		    "OUTER OF LAYOUT"
35
		));
36
	}
37
38
39
	public function testNoTemplateOverride() {
40
		$this->logInWithPermission('ADMIN');
41
		$page = $this->objFromFixture('Page', 'page1');
42
		$page->AlternativeTemplate = null;
43
		$page->write();
44
		$page->doPublish();
45
		$response = $this->get('/' . $page->URLSegment);
46
        $this->assertEquals(200, $response->getStatusCode());
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PageControllerTem...eOverrideExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
        $body = $response->getBody();
48
        $this->assertNotContains('OUTER OF LAYOUT', $body);
49
        $this->assertNotContains('INNER LAYOUT', $body);
50
	}
51
52
53
}
54