Page MenuHomeWickedGov Phorge

CustomHeaderDeviceDetectorTest.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

CustomHeaderDeviceDetectorTest.php

<?php
namespace Tests\MobileFrontend\Devices;
use MediaWiki\Config\HashConfig;
use MediaWiki\Request\FauxRequest;
use MobileFrontend\Devices\CustomHeaderDeviceDetector;
/**
* @group MobileFrontend
*/
class CustomHeaderDeviceDetectorTest extends \MediaWikiUnitTestCase {
/**
* @var \MobileFrontend\Devices\UADeviceDetector
*/
private $detector;
/**
* @var FauxRequest
*/
private $request;
protected function setUp(): void {
parent::setUp();
$config = new HashConfig();
$config->set( 'MFMobileHeader', 'FooHeader' );
$this->detector = new CustomHeaderDeviceDetector( $config );
$this->request = new FauxRequest();
}
/**
* @covers \MobileFrontend\Devices\CustomHeaderDeviceDetector::detectDeviceProperties
*/
public function testIsNullWhenCustomHeaderIsntPresent() {
$this->assertNull(
$this->detector->detectDeviceProperties( $this->request, [] )
);
}
/**
* @covers \MobileFrontend\Devices\CustomHeaderDeviceDetector::detectDeviceProperties
* @covers \MobileFrontend\Devices\CustomHeaderDeviceDetector::__construct
* @covers \MobileFrontend\Devices\DeviceProperties::isMobileDevice
* @covers \MobileFrontend\Devices\DeviceProperties::isTabletDevice
*/
public function testIsMobileWhenMobileHeaderIsPresent() {
$this->request->setHeader( 'FooHeader', '' );
$properties = $this->detector->detectDeviceProperties( $this->request, [] );
$this->assertTrue( $properties->isMobileDevice() );
$this->assertFalse( $properties->isTabletDevice() );
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Nov 23, 03:50 (3 d, 4 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4e/92/f244311465f297afe6c2d5267b12
Default Alt Text
CustomHeaderDeviceDetectorTest.php (1 KB)

Event Timeline