本文整理匯總了PHP中Mobile_Detect::setCfHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mobile_Detect::setCfHeaders方法的具體用法?PHP Mobile_Detect::setCfHeaders怎麽用?PHP Mobile_Detect::setCfHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mobile_Detect
的用法示例。
在下文中一共展示了Mobile_Detect::setCfHeaders方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetCfHeaders
/**
* Read response from cloudfront, if the cloudfront headers are detected
* @covers Mobile_Detect::setCfHeaders
*/
public function testSetCfHeaders()
{
// Test mobile detected
$header1 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'true', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'false');
$md = new Mobile_Detect($header1);
$this->assertSame($md->getCfHeaders(), $header1);
$this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
$this->assertSame($md->isTablet(), false);
$this->assertSame($md->isMobile(), true);
// Test neither mobile nor tablet (desktop)
$header2 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'true', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'false');
$md->setHttpHeaders($header2);
$this->assertSame($md->getCfHeaders(), $header2);
$this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
$this->assertSame($md->isTablet(), false);
$this->assertSame($md->isMobile(), false);
// Test tablet detected
$header3 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'true');
$md->setCfHeaders($header3);
$this->assertSame($md->getCfHeaders(), $header3);
$this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
$this->assertSame($md->isTablet(), true);
$this->assertSame($md->isMobile(), false);
// Check if the headers are cleared
$header4 = array();
$md->setHttpHeaders($header4);
$this->assertSame($md->getCfHeaders(), $header4);
}