Completed
Push — 3.1 ( 316979...c241b3 )
by Gordon
14:16 queued 06:13
created

testNoTemplateOverride()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 12
rs 9.4286
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
class PageControllerTemplateOverrideExtensionTest extends FunctionalTest {
4
5
	protected static $fixture_file = 'template-override/tests/pages.yml';
6
7 View Code Duplication
	public function testLayoutTemplateOveride() {
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());
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() {
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());
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());
47
		$body = $response->getBody();
48
		$this->assertNotContains('OUTER OF LAYOUT', $body);
49
		$this->assertNotContains('INNER LAYOUT', $body);
50
	}
51
52
53
}
54