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
|
|
|
{ |
9
|
1 |
|
$this->logInWithPermission('ADMIN'); |
10
|
1 |
|
$page = $this->objFromFixture('Page', 'page1'); |
11
|
1 |
|
$page->AlternativeTemplate = 'PageInnerTest'; |
12
|
1 |
|
$page->write(); |
13
|
1 |
|
$page->doPublish(); |
14
|
1 |
|
$response = $this->get('/'.$page->URLSegment); |
15
|
1 |
|
$this->assertEquals(200, $response->getStatusCode()); |
16
|
|
|
|
17
|
|
|
// assert the the inner layout template has been used |
18
|
1 |
|
$this->assertExactMatchBySelector('div.marker', array( |
19
|
1 |
|
'INNER LAYOUT', |
20
|
1 |
|
)); |
21
|
1 |
|
} |
22
|
|
|
|
23
|
1 |
View Code Duplication |
public function testOuterTemplateOveride() |
24
|
|
|
{ |
25
|
1 |
|
$this->logInWithPermission('ADMIN'); |
26
|
1 |
|
$page = $this->objFromFixture('Page', 'page1'); |
27
|
1 |
|
$page->AlternativeTemplate = 'PageOuterTest'; |
28
|
1 |
|
$page->write(); |
29
|
1 |
|
$page->doPublish(); |
30
|
1 |
|
$response = $this->get('/'.$page->URLSegment); |
31
|
1 |
|
$this->assertEquals(200, $response->getStatusCode()); |
32
|
|
|
|
33
|
|
|
// show the the outer layout template has been used |
34
|
1 |
|
$this->assertExactMatchBySelector('div.marker', array( |
35
|
1 |
|
'OUTER OF LAYOUT', |
36
|
1 |
|
)); |
37
|
1 |
|
} |
38
|
|
|
|
39
|
1 |
|
public function testNoTemplateOverride() |
40
|
|
|
{ |
41
|
1 |
|
$this->logInWithPermission('ADMIN'); |
42
|
1 |
|
$page = $this->objFromFixture('Page', 'page1'); |
43
|
1 |
|
$page->AlternativeTemplate = null; |
44
|
1 |
|
$page->write(); |
45
|
1 |
|
$page->doPublish(); |
46
|
1 |
|
$response = $this->get('/'.$page->URLSegment); |
47
|
1 |
|
$this->assertEquals(200, $response->getStatusCode()); |
48
|
1 |
|
$body = $response->getBody(); |
49
|
1 |
|
$this->assertNotContains('OUTER OF LAYOUT', $body); |
50
|
1 |
|
$this->assertNotContains('INNER LAYOUT', $body); |
51
|
1 |
|
} |
52
|
|
|
} |
53
|
|
|
|