本文整理汇总了PHP中Subsite::strict_subdomain_matching方法的典型用法代码示例。如果您正苦于以下问题:PHP Subsite::strict_subdomain_matching方法的具体用法?PHP Subsite::strict_subdomain_matching怎么用?PHP Subsite::strict_subdomain_matching使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subsite
的用法示例。
在下文中一共展示了Subsite::strict_subdomain_matching方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
parent::tearDown();
Subsite::$strict_subdomain_matching = $this->origStrictSubdomainMatching;
}
示例2: testStrictSubdomainMatching
function testStrictSubdomainMatching()
{
// Clear existing fixtures
foreach (DataObject::get('Subsite') as $subsite) {
$subsite->delete();
}
foreach (DataObject::get('SubsiteDomain') as $domain) {
$domain->delete();
}
// Much more expressive than YML in this case
$subsite1 = $this->createSubsiteWithDomains(array('example.org' => true, 'example.com' => false, '*.wildcard.com' => false));
$subsite2 = $this->createSubsiteWithDomains(array('www.example.org' => true, 'www.wildcard.com' => false));
Subsite::$strict_subdomain_matching = false;
$this->assertEquals($subsite1->ID, Subsite::getSubsiteIDForDomain('example.org'), 'Exact matches without strict checking when not using www prefix');
$this->assertEquals($subsite1->ID, Subsite::getSubsiteIDForDomain('www.example.org'), 'Matches without strict checking when using www prefix, still matching first domain regardless of www prefix (falling back to subsite primary key ordering)');
$this->assertEquals($subsite1->ID, Subsite::getSubsiteIDForDomain('www.example.com'), 'Fuzzy matches without strict checking with www prefix');
$this->assertEquals(0, Subsite::getSubsiteIDForDomain('www.wildcard.com'), 'Doesn\'t match www prefix without strict check, even if a wildcard subdomain is in place');
Subsite::$strict_subdomain_matching = true;
$this->assertEquals($subsite1->ID, Subsite::getSubsiteIDForDomain('example.org'), 'Matches with strict checking when not using www prefix');
$this->assertEquals($subsite2->ID, Subsite::getSubsiteIDForDomain('www.example.org'), 'Matches with strict checking when using www prefix');
$this->assertEquals(0, Subsite::getSubsiteIDForDomain('www.example.com'), 'Doesn\'t fuzzy match with strict checking when using www prefix');
$failed = false;
try {
Subsite::getSubsiteIDForDomain('www.wildcard.com');
} catch (UnexpectedValueException $e) {
$failed = true;
}
$this->assertTrue($failed, 'Fails on multiple matches with strict checking and wildcard vs. www');
}