Completed
Push — 3.1 ( 269ff1 )
by Gordon
06:46
created

testLayoutTemplateOveride()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 1
Metric Value
dl 14
loc 14
ccs 11
cts 11
cp 1
rs 9.4286
cc 1
eloc 10
nc 1
nop 0
crap 1
1
<?php
2
3
class PageControllerTemplateOverrideExtensionTest extends FunctionalTest {
4
5
	protected static $fixture_file = 'template-override/tests/pages.yml';
6
7 1 View Code Duplication
	public function testLayoutTemplateOveride() {
8 1
		$this->logInWithPermission('ADMIN');
9 1
		$page = $this->objFromFixture('Page', 'page1');
10 1
		$page->AlternativeTemplate = 'PageInnerTest';
11 1
		$page->write();
12 1
		$page->doPublish();
13 1
		$response = $this->get('/' . $page->URLSegment);
14 1
		$this->assertEquals(200, $response->getStatusCode());
15
16
		// assert the the inner layout template has been used
17 1
		$this->assertExactMatchBySelector("div.marker", array(
18
			"INNER LAYOUT"
19 1
		));
20 1
	}
21
22
23 1 View Code Duplication
	public function testOuterTemplateOveride() {
24 1
		$this->logInWithPermission('ADMIN');
25 1
		$page = $this->objFromFixture('Page', 'page1');
26 1
		$page->AlternativeTemplate = 'PageOuterTest';
27 1
		$page->write();
28 1
		$page->doPublish();
29 1
		$response = $this->get('/' . $page->URLSegment);
30 1
		$this->assertEquals(200, $response->getStatusCode());
31
32
		// show the the outer layout template has been used
33 1
		$this->assertExactMatchBySelector("div.marker", array(
34
			"OUTER OF LAYOUT"
35 1
		));
36 1
	}
37
38
39 1
	public function testNoTemplateOverride() {
40 1
		$this->logInWithPermission('ADMIN');
41 1
		$page = $this->objFromFixture('Page', 'page1');
42 1
		$page->AlternativeTemplate = null;
43 1
		$page->write();
44 1
		$page->doPublish();
45 1
		$response = $this->get('/' . $page->URLSegment);
46 1
		$this->assertEquals(200, $response->getStatusCode());
47 1
		$body = $response->getBody();
48 1
		$this->assertNotContains('OUTER OF LAYOUT', $body);
49 1
		$this->assertNotContains('INNER LAYOUT', $body);
50 1
	}
51
52
53
}
54