CompatibilityChecker::COMPATIBILITY_NONE, 'os' => 'Windows', 'osVersion' => '7', 'device' => 'desktop', 'browser' => 'Internet Explorer', 'versions' => [9]], ['compatible' => CompatibilityChecker::COMPATIBILITY_COMPATIBLE, 'os' => 'Windows', 'osVersion' => '8.1', 'device' => 'desktop', 'browser' => 'Chrome', 'versions' => [33, 34, 35]], ]; $supported = [ ['compatible' => CompatibilityChecker::COMPATIBILITY_SUPPORTED, 'os' => 'Windows', 'osVersion' => '8.1', 'device' => 'desktop', 'browser' => 'Chrome', 'versions' => [40, 41, 42]], ]; $excludedBrowsers = [ 'chrome' => ['43'] ]; $excludedOS = [ 'windows' => ['10'] ]; $checker = new CompatibilityCheckerDummy( $compatibility, $supported, $excludedBrowsers, $excludedOS, $this->getDetectorMock(Os::class, $osName, $osVersion, false), $this->getDetectorMock(Browser::class, $browserName, $browserVersion, false) ); $this->assertEquals($checker->isCompatibleConfig(), $expectedResult); } protected function getDetectorMock($class, $name, $version, $mobile) { $detector = $this->getMockBuilder($class) ->disableOriginalConstructor() ->setMethods(['getName', 'getVersion', 'isMobile']) ->getMock(); $detector->expects($this->any()) ->method('getName') ->willReturn($name); $detector->expects($this->any()) ->method('getVersion') ->willReturn($version); $detector->expects($this->any()) ->method('isMobile') ->willReturn($mobile); return $detector; } } class CompatibilityCheckerDummy extends CompatibilityChecker { private $osDetector; private $browserDetector; public function __construct($compatibility, $supported, $excludedBrowsers, $excludedOS, $osDetector, $browserDetector) { $this->compatibility = $compatibility; $this->supported = $supported; $this->excludedBrowsers = $excludedBrowsers; $this->excludedOS = $excludedOS; $this->osDetector = $osDetector; $this->browserDetector = $browserDetector; } protected function getBrowserDetector(): Browser { return $this->browserDetector; } public function getOsDetector(): Os { return $this->osDetector; } }