Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #47 from elricho/master
Browse files Browse the repository at this point in the history
BugFix : Ticket 13452-2 iOS version not overlayed into device profile…
  • Loading branch information
elricho authored Oct 5, 2016
2 parents bc67592 + c963def commit 70ec620
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/HDBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/HDDevice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
120 changes: 116 additions & 4 deletions tests/hd4Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 70ec620

Please sign in to comment.