2011-03-24 11:30:20 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Tests for the template manifest.
|
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2011-03-24 11:30:20 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class TemplateManifestTest extends SapphireTest {
|
|
|
|
|
|
|
|
protected $base;
|
|
|
|
protected $manifest;
|
|
|
|
protected $manifestTests;
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->base = dirname(__FILE__) . '/fixtures/templatemanifest';
|
2012-11-02 08:28:39 +01:00
|
|
|
$this->manifest = new SS_TemplateManifest($this->base, 'myproject');
|
|
|
|
$this->manifestTests = new SS_TemplateManifest($this->base, 'myproject', true);
|
2011-03-24 11:30:20 +01:00
|
|
|
|
|
|
|
$this->manifest->regenerate(false);
|
|
|
|
$this->manifestTests->regenerate(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTemplates() {
|
|
|
|
$expect = array(
|
|
|
|
'root' => array(
|
|
|
|
'module' => "{$this->base}/module/Root.ss"
|
|
|
|
),
|
|
|
|
'page' => array(
|
|
|
|
'main' => "{$this->base}/module/templates/Page.ss",
|
|
|
|
'Layout' => "{$this->base}/module/templates/Layout/Page.ss",
|
|
|
|
'themes' => array('theme' => array(
|
|
|
|
'main' => "{$this->base}/themes/theme/templates/Page.ss",
|
|
|
|
'Layout' => "{$this->base}/themes/theme/templates/Layout/Page.ss"
|
|
|
|
))
|
|
|
|
),
|
|
|
|
'custompage' => array(
|
|
|
|
'Layout' => "{$this->base}/module/templates/Layout/CustomPage.ss"
|
|
|
|
),
|
2012-11-02 08:28:39 +01:00
|
|
|
'customtemplate' => array(
|
|
|
|
'main' => "{$this->base}/module/templates/CustomTemplate.ss",
|
|
|
|
'myproject' => array(
|
|
|
|
'main' => "{$this->base}/myproject/templates/CustomTemplate.ss"
|
|
|
|
)
|
|
|
|
),
|
2011-03-24 11:30:20 +01:00
|
|
|
'subfolder' => array(
|
|
|
|
'main' => "{$this->base}/module/subfolder/templates/Subfolder.ss"
|
|
|
|
),
|
2013-04-29 17:19:51 +02:00
|
|
|
'customthemepage' => array (
|
2013-08-21 08:54:05 +02:00
|
|
|
'Layout' => "{$this->base}/module/templates/Layout/CustomThemePage.ss",
|
|
|
|
'themes' =>
|
|
|
|
array(
|
|
|
|
'theme' => array('main' => "{$this->base}/themes/theme/templates/CustomThemePage.ss",)
|
|
|
|
)
|
2013-04-29 17:19:51 +02:00
|
|
|
),
|
2011-03-24 11:30:20 +01:00
|
|
|
'include' => array('themes' => array(
|
|
|
|
'theme' => array(
|
|
|
|
'Includes' => "{$this->base}/themes/theme/templates/Includes/Include.ss"
|
|
|
|
)
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
$expectTests = $expect;
|
|
|
|
$expectTests['test'] = array(
|
|
|
|
'main' => "{$this->base}/module/tests/templates/Test.ss"
|
|
|
|
);
|
|
|
|
|
|
|
|
$manifest = $this->manifest->getTemplates();
|
|
|
|
$manifestTests = $this->manifestTests->getTemplates();
|
|
|
|
|
|
|
|
ksort($expect);
|
|
|
|
ksort($expectTests);
|
|
|
|
ksort($manifest);
|
|
|
|
ksort($manifestTests);
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-03-24 11:30:20 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$expect, $manifest,
|
|
|
|
'All templates are correctly loaded in the manifest.'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
$expectTests, $manifestTests,
|
|
|
|
'The test manifest is the same, but includes test templates.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTemplate() {
|
|
|
|
$expectPage = array(
|
|
|
|
'main' => "{$this->base}/module/templates/Page.ss",
|
|
|
|
'Layout' => "{$this->base}/module/templates/Layout/Page.ss",
|
|
|
|
'themes' => array('theme' => array(
|
|
|
|
'main' => "{$this->base}/themes/theme/templates/Page.ss",
|
|
|
|
'Layout' => "{$this->base}/themes/theme/templates/Layout/Page.ss"
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
$expectTests = array(
|
|
|
|
'main' => "{$this->base}/module/tests/templates/Test.ss"
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals($expectPage, $this->manifest->getTemplate('Page'));
|
|
|
|
$this->assertEquals($expectPage, $this->manifest->getTemplate('PAGE'));
|
|
|
|
$this->assertEquals($expectPage, $this->manifestTests->getTemplate('Page'));
|
|
|
|
$this->assertEquals($expectPage, $this->manifestTests->getTemplate('PAGE'));
|
|
|
|
|
|
|
|
$this->assertEquals(array(), $this->manifest->getTemplate('Test'));
|
|
|
|
$this->assertEquals($expectTests, $this->manifestTests->getTemplate('Test'));
|
2012-11-02 08:28:39 +01:00
|
|
|
|
|
|
|
$this->assertEquals(array(
|
|
|
|
'main' => "{$this->base}/module/templates/CustomTemplate.ss",
|
|
|
|
'myproject' => array(
|
2014-08-15 08:53:05 +02:00
|
|
|
'main' => "{$this->base}/myproject/templates/CustomTemplate.ss"
|
2012-11-02 08:28:39 +01:00
|
|
|
)), $this->manifestTests->getTemplate('CustomTemplate'));
|
2011-03-24 11:30:20 +01:00
|
|
|
}
|
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|