コード例 #1
0
ファイル: i18nTest.php プロジェクト: redema/sapphire
	function setUp() {
		parent::setUp();
		
		$this->alternateBasePath = $this->getCurrentAbsolutePath() . "/_fakewebroot";
		$this->alternateBaseSavePath = TEMP_FOLDER . '/i18nTextCollectorTest_webroot';
		FileSystem::makeFolder($this->alternateBaseSavePath);
		Director::setBaseFolder($this->alternateBasePath);

		// Push a template loader running from the fake webroot onto the stack.
		$templateManifest = new SS_TemplateManifest($this->alternateBasePath, false, true);
		$templateManifest->regenerate(false);
		SS_TemplateLoader::instance()->pushManifest($templateManifest);
		$this->_oldTheme = SSViewer::current_theme();
		SSViewer::set_theme('testtheme1');

		$this->originalLocale = i18n::get_locale();
		
		// Override default adapter to avoid cached translations between tests.
		// Emulates behaviour in i18n::get_translators()
		$this->origAdapter = i18n::get_translator('core');
		$adapter = new Zend_Translate(array(
			'adapter' => 'i18nRailsYamlAdapter',
			'locale' => i18n::default_locale(),
			'disableNotices' => true,
		));
		i18n::register_translator($adapter, 'core');
		$adapter->removeCache();
		i18n::include_by_locale('en');
	}
コード例 #2
0
	public function testFindTemplates() {
		$base     = dirname(__FILE__) . '/fixtures/templatemanifest';
		$manifest = new SS_TemplateManifest($base, false, true);
		$loader   = new SS_TemplateLoader();

		$manifest->regenerate(false);
		$loader->pushManifest($manifest);

		$expectPage = array(
			'main'   => "$base/module/templates/Page.ss",
			'Layout' => "$base/module/templates/Layout/Page.ss"
		);
		$expectPageThemed = array(
			'main'   => "$base/themes/theme/templates/Page.ss",
			'Layout' => "$base/themes/theme/templates/Layout/Page.ss"
		);

		$this->assertEquals($expectPage, $loader->findTemplates('Page'));
		$this->assertEquals($expectPage, $loader->findTemplates(array('Foo', 'Page')));
		$this->assertEquals($expectPage, $loader->findTemplates('PAGE'));
		$this->assertEquals($expectPageThemed, $loader->findTemplates('Page', 'theme'));

		$expectPageLayout       = array('main' => "$base/module/templates/Layout/Page.ss");
		$expectPageLayoutThemed = array('main' => "$base/themes/theme/templates/Layout/Page.ss");

		$this->assertEquals($expectPageLayout, $loader->findTemplates('Layout/Page'));
		$this->assertEquals($expectPageLayout, $loader->findTemplates('Layout/PAGE'));
		$this->assertEquals($expectPageLayoutThemed, $loader->findTemplates('Layout/Page', 'theme'));

		$expectCustomPage = array(
			'main'   => "$base/module/templates/Page.ss",
			'Layout' => "$base/module/templates/Layout/CustomPage.ss"
		);
		$this->assertEquals($expectCustomPage, $loader->findTemplates(array('CustomPage', 'Page')));
	}
コード例 #3
0
 function setUp()
 {
     parent::setUp();
     $this->alternateBasePath = $this->getCurrentAbsolutePath() . "/_fakewebroot";
     $this->alternateBaseSavePath = TEMP_FOLDER . '/i18nTextCollectorTest_webroot';
     FileSystem::makeFolder($this->alternateBaseSavePath);
     // Push a template loader running from the fake webroot onto the stack.
     $manifest = new SS_TemplateManifest($this->alternateBasePath, false, true);
     $manifest->regenerate(false);
     SS_TemplateLoader::instance()->pushManifest($manifest);
     $this->originalLocale = i18n::get_locale();
 }
コード例 #4
0
 public function setUp()
 {
     parent::setUp();
     $this->alternateBasePath = $this->getCurrentAbsolutePath() . "/_fakewebroot";
     $this->alternateBaseSavePath = TEMP_FOLDER . '/i18nTextCollectorTest_webroot';
     Filesystem::makeFolder($this->alternateBaseSavePath);
     // Push a class and template loader running from the fake webroot onto
     // the stack.
     $this->manifest = new SS_ClassManifest($this->alternateBasePath, false, true, false);
     $manifest = new SS_TemplateManifest($this->alternateBasePath, null, false, true);
     $manifest->regenerate(false);
     SS_TemplateLoader::instance()->pushManifest($manifest);
 }
コード例 #5
0
/**
 * Clears the template manifest
 * @param string $project
 * @return void
 */
function clear_templates($project = 'mysite')
{
    $manifest = new \SS_TemplateManifest(BASE_PATH, $project);
    $manifest->regenerate(true);
    \SSViewer::flush_template_cache();
}