当前位置: 首页>>代码示例>>PHP>>正文


PHP RootURLController::get_homepage_urlsegment方法代码示例

本文整理汇总了PHP中RootURLController::get_homepage_urlsegment方法的典型用法代码示例。如果您正苦于以下问题:PHP RootURLController::get_homepage_urlsegment方法的具体用法?PHP RootURLController::get_homepage_urlsegment怎么用?PHP RootURLController::get_homepage_urlsegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RootURLController的用法示例。


在下文中一共展示了RootURLController::get_homepage_urlsegment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHomepageForDomain

 function testHomepageForDomain()
 {
     $originalHost = $_SERVER['HTTP_HOST'];
     // Tests matching an HTTP_HOST value to URLSegment homepage values
     $tests = array('page.co.nz' => 'page1', 'www.page.co.nz' => 'page1', 'help.com' => 'page1', 'www.help.com' => 'page1', 'something.com' => 'page1', 'www.something.com' => 'page1', 'other.co.nz' => 'page2', 'www.other.co.nz' => 'page2', 'right' => 'page2', 'www. right' => 'page2', 'only.com' => 'page3', 'www.only.com' => 'page3', 'www.somethingelse.com' => 'home', 'somethingelse.com' => 'home', 'alternate.only.com' => 'home', 'www.alternate.only.com' => 'home', 'alternate.something.com' => 'home');
     foreach ($tests as $domain => $urlSegment) {
         $_SERVER['HTTP_HOST'] = $domain;
         $this->assertEquals($urlSegment, RootURLController::get_homepage_urlsegment(Translatable::default_locale()), "Testing {$domain} matches {$urlSegment}");
     }
     $_SERVER['HTTP_HOST'] = $originalHost;
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:11,代码来源:RootURLControllerTest.php

示例2: testHomepageForDomain

	function testHomepageForDomain() {
		$originalHost = $_SERVER['HTTP_HOST'];

		// Tests matching an HTTP_HOST value to URLSegment homepage values
		$tests = array(
			'page.co.nz' => 'page1',
			'www.page.co.nz' => 'page1',
			'help.com' => 'page1',
			'www.help.com' => 'page1',
			'something.com' => 'page1',
			'www.something.com' => 'page1',

	 		'other.co.nz' => 'page2',
	 		'www.other.co.nz' => 'page2',
			'right' => 'page2',
			'www. right' => 'page2',

			'only.com' => 'page3',
			'www.only.com' => 'page3',
			
			'www.somethingelse.com' => 'home',
			'somethingelse.com' => 'home',
			
			// Test some potential false matches to page2 and page3
			'alternate.only.com' => 'home',
			'www.alternate.only.com' => 'home',
			'alternate.something.com' => 'home',
		);
		
		foreach($tests as $domain => $urlSegment) {
			$_SERVER['HTTP_HOST'] = $domain;
			$this->assertEquals($urlSegment, RootURLController::get_homepage_urlsegment(), "Testing $domain matches $urlSegment");
		}
		
		$_SERVER['HTTP_HOST'] = $originalHost;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:36,代码来源:RootURLControllerTest.php

示例3: testRootUrlDefaultsToTranslatedUrlSegment

 function testRootUrlDefaultsToTranslatedUrlSegment()
 {
     $origPage = $this->objFromFixture('Page', 'homepage_en');
     $origPage->publish('Stage', 'Live');
     $translationDe = $origPage->createTranslation('de_DE');
     $translationDe->URLSegment = 'heim';
     $translationDe->write();
     $translationDe->publish('Stage', 'Live');
     // test with translatable
     Translatable::set_current_locale('de_DE');
     $this->assertEquals(RootURLController::get_homepage_urlsegment(), 'heim', 'Homepage with different URLSegment in non-default language is found');
     // @todo Fix add/remove extension
     // test with translatable disabled
     // Object::remove_extension('Page', 'Translatable');
     // 		$_SERVER['HTTP_HOST'] = '/';
     // 		$this->assertEquals(
     // 			RootURLController::get_homepage_urlsegment(),
     // 			'home',
     // 			'Homepage is showing in default language if ?lang GET variable is left out'
     // 		);
     // 		Object::add_extension('Page', 'Translatable');
     // setting back to default
     Translatable::set_current_locale('en_US');
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:24,代码来源:TranslatableTest.php


注:本文中的RootURLController::get_homepage_urlsegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。