diff --git a/src/HDBase.php b/src/HDBase.php index 91edeea..ffe5a63 100644 --- a/src/HDBase.php +++ b/src/HDBase.php @@ -70,7 +70,7 @@ class HDBase { array('ro-build-id', 'ro-build-version-release'), ), 'ios' => array( - array('uidevice.systemName','uidevice.systemversion') + array('uidevice.systemname','uidevice.systemversion') ), 'windows phone' => array( array('osname','osversion') diff --git a/src/HDDevice.php b/src/HDDevice.php index 4c44629..fe5828f 100644 --- a/src/HDDevice.php +++ b/src/HDDevice.php @@ -500,7 +500,7 @@ function v4MatchBuildInfo($buildInfo) { // Platform Detection $this->platform = $this->v4MatchBIHelper($buildInfo, 'platform'); if (! empty($this->platform)) - $this->specsOverlay('platform', $this->device, $this->platform); + $this->specsOverlay('platform', $this->device, $this->platform['Extra']); $this->reply['hd_specs'] = $this->device['Device']['hd_specs']; return $this->setError(0, "OK"); diff --git a/tests/hd4Test.php b/tests/hd4Test.php index ef49518..430ac62 100644 --- a/tests/hd4Test.php +++ b/tests/hd4Test.php @@ -183,7 +183,7 @@ function test_deviceDetectHTTPDesktop() { function test_deviceDetectHTTPDesktopJunk() { $hd = new HandsetDetection\HD4($this->cloudConfig); $headers = array( - 'User-Agent' => 'aksjakdjkjdaiwdidjkjdkawjdijwidawjdiajwdkawdjiwjdiawjdwidjwakdjajdkad'.time() + 'User-Agent' => 'aksjakdjkjdaiwdidjkjdkawjdijwidawjdiajwdkawdjiwjdiawjdwidjwakdjajdkad' ); $result = $hd->deviceDetect($headers); @@ -359,6 +359,27 @@ function test_deviceDetectHTTPHardwareInfoC() { $this->assertArrayHasKey('benchmark_max', $reply['hd_specs']); } + /** + * Detection test user-agent has been encoded with plus for space. + * @depends test_cloudConfigExists + * @group cloud + **/ + function test_deviceDetectHTTPPlusForSpace() { + $hd = new HandsetDetection\HD4($this->cloudConfig); + $headers = array( + 'user-agent' => 'Mozilla/5.0+(Linux;+Android+5.1.1;+SM-J110M+Build/LMY48B;+wv)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Version/4.0+Chrome/47.0.2526.100+Mobile+Safari/537.36', + ); + + $result = $hd->deviceDetect($headers); + $reply = $hd->getReply(); + $this->assertTrue($result); + $this->assertEquals('Samsung', $reply['hd_specs']['general_vendor']); + $this->assertEquals('SM-J110M', $reply['hd_specs']['general_model']); + $this->assertEquals('Android', $reply['hd_specs']['general_platform']); + $this->assertEquals('5.1.1', $reply['hd_specs']['general_platform_version']); + $this->assertEquals('Mobile', $reply['hd_specs']['general_type']); + } + /** * Detection test iPhone 5s running Facebook 9.0 app (hence no general_browser set). * @depends test_cloudConfigExists @@ -474,6 +495,32 @@ function test_deviceDetectBIiOS() { $this->assertEquals('Mobile', $reply['hd_specs']['general_type']); } + /** + * Detection test iPhone 4S Native + * @depends test_cloudConfigExists + * @group cloud + **/ + function test_deviceDetectBIiOSOverlayPlatform() { + $buildInfo = array ( + 'utsname.machine' => 'iphone4,1', + 'utsname.brand' => 'Apple', + 'uidevice.systemversion' => '5.1', + 'uidevice.systemname' => 'iphone os' + ); + + $hd = new HandsetDetection\HD4($this->cloudConfig); + $result = $hd->deviceDetect($buildInfo); + $reply = $hd->getReply(); + + //print_r(json_encode($reply)); + + $this->assertEquals('Apple', $reply['hd_specs']['general_vendor']); + $this->assertEquals('iPhone 4S', $reply['hd_specs']['general_model']); + $this->assertEquals('iOS', $reply['hd_specs']['general_platform']); + $this->assertEquals('5.1', $reply['hd_specs']['general_platform_version']); + $this->assertEquals('Mobile', $reply['hd_specs']['general_type']); + } + /** * Detection test Windows Phone Native Nokia Lumia 1020 * @depends test_cloudConfigExists @@ -623,7 +670,7 @@ function test_ultimate_deviceDetectHTTPDesktop() { function test_ultimate_deviceDetectHTTPDesktopJunk() { $hd = new HandsetDetection\HD4($this->ultimateConfig); $headers = array( - 'User-Agent' => 'aksjakdjkjdaiwdidjkjdkawjdijwidawjdiajwdkawdjiwjdiawjdwidjwakdjajdkad'.time() + 'User-Agent' => 'aksjakdjkjdaiwdidjkjdkawjdijwidawjdiajwdkawdjiwjdiawjdwidjwakdjajdkad' ); $result = $hd->deviceDetect($headers); @@ -799,6 +846,27 @@ function test_ultimate_deviceDetectHTTPHardwareInfoC() { $this->assertArrayHasKey('benchmark_max', $reply['hd_specs']); } + /** + * Detection test user-agent has been encoded with plus for space. + * @depends test_fetchArchive + * @group ultimate + **/ + function test_ultimate_deviceDetectHTTPPlusForSpace() { + $hd = new HandsetDetection\HD4($this->ultimateConfig); + $headers = array( + 'user-agent' => 'Mozilla/5.0+(Linux;+Android+5.1.1;+SM-J110M+Build/LMY48B;+wv)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Version/4.0+Chrome/47.0.2526.100+Mobile+Safari/537.36', + ); + + $result = $hd->deviceDetect($headers); + $reply = $hd->getReply(); + $this->assertTrue($result); + $this->assertEquals('Samsung', $reply['hd_specs']['general_vendor']); + $this->assertEquals('SM-J110M', $reply['hd_specs']['general_model']); + $this->assertEquals('Android', $reply['hd_specs']['general_platform']); + $this->assertEquals('5.1.1', $reply['hd_specs']['general_platform_version']); + $this->assertEquals('Mobile', $reply['hd_specs']['general_type']); + } + /** * iPhone 5s running Facebook 9.0 app (hence no general_browser set). * @depends test_fetchArchive @@ -894,7 +962,7 @@ function test_ultimate_deviceDetectBIAndroid() { function test_ultimate_deviceDetectBIiOS() { $buildInfo = array ( 'utsname.machine' => 'iphone4,1', - 'utsname.brand' => 'Apple' + 'utsname.brand' => 'Apple', ); $hd = new HandsetDetection\HD4($this->ultimateConfig); @@ -909,6 +977,29 @@ function test_ultimate_deviceDetectBIiOS() { $this->assertEquals('Mobile', $reply['hd_specs']['general_type']); } + /** + * Detection test iPhone 4S Native + * @depends test_fetchArchive + * @group ultimate + **/ + function test_ultimate_deviceDetectBIiOSOverlayPlatform() { + $buildInfo = array ( + 'utsname.machine' => 'iphone4,1', + 'utsname.brand' => 'Apple', + 'uidevice.systemversion' => '5.1', + 'uidevice.systemname' => 'iphone os' + ); + + $hd = new HandsetDetection\HD4($this->ultimateConfig); + $result = $hd->deviceDetect($buildInfo); + $reply = $hd->getReply(); + + $this->assertEquals('Apple', $reply['hd_specs']['general_vendor']); + $this->assertEquals('iPhone 4S', $reply['hd_specs']['general_model']); + $this->assertEquals('iOS', $reply['hd_specs']['general_platform']); + $this->assertEquals('5.1', $reply['hd_specs']['general_platform_version']); + $this->assertEquals('Mobile', $reply['hd_specs']['general_type']); + } // /** * Windows Phone Native Nokia Lumia 1020 @@ -995,7 +1086,7 @@ function test_ultimate_community_deviceDetectHTTPDesktop() { function test_ultimate_community_deviceDetectHTTPDesktopJunk() { $hd = new HandsetDetection\HD4($this->ultimateConfig); $headers = array( - 'User-Agent' => 'aksjakdjkjdaiwdidjkjdkawjdijwidawjdiajwdkawdjiwjdiawjdwidjwakdjajdkad'.time() + 'User-Agent' => 'aksjakdjkjdaiwdidjkjdkawjdijwidawjdiajwdkawdjiwjdiawjdwidjwakdjajdkad' ); $result = $hd->deviceDetect($headers); @@ -1171,6 +1262,27 @@ function test_ultimate_community_deviceDetectHTTPHardwareInfoC() { $this->assertArrayHasKey('benchmark_max', $reply['hd_specs']); } + /** + * Detection test user-agent has been encoded with plus for space. + * @depends test_ultimate_community_fetchArchive + * @group community + **/ + function test_ultimate_community_deviceDetectHTTPPlusForSpace() { + $hd = new HandsetDetection\HD4($this->ultimateConfig); + $headers = array( + 'user-agent' => 'Mozilla/5.0+(Linux;+Android+5.1.1;+SM-J110M+Build/LMY48B;+wv)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Version/4.0+Chrome/47.0.2526.100+Mobile+Safari/537.36', + ); + + $result = $hd->deviceDetect($headers); + $reply = $hd->getReply(); + $this->assertTrue($result); + $this->assertEquals('Samsung', $reply['hd_specs']['general_vendor']); + $this->assertEquals('SM-J110M', $reply['hd_specs']['general_model']); + $this->assertEquals('Android', $reply['hd_specs']['general_platform']); + $this->assertEquals('5.1.1', $reply['hd_specs']['general_platform_version']); + $this->assertEquals('', $reply['hd_specs']['general_type']); + } + /** * iPhone 5s running Facebook 9.0 app (hence no general_browser set). * @depends test_ultimate_community_fetchArchive