Esempio n. 1
0
 static function setUpBeforeClass()
 {
     $dir = sys_get_temp_dir();
     $file = $dir . DIRECTORY_SEPARATOR . "communityTest.zip";
     $hd4 = new HandsetDetection\HD4();
     $store = HandsetDetection\HDStore::getInstance();
     $store->setPath($dir, true);
     $hd4->remote("community/fetcharchive", '', 'zip', false);
     $status = file_put_contents($dir . DIRECTORY_SEPARATOR . "communityTest.zip", $hd4->getRawReply());
     $zip = new \ZipArchive();
     if ($zip->open($file) === false) {
         return false;
     }
     for ($i = 0; $i < $zip->numFiles; $i++) {
         $filename = $zip->getNameIndex($i);
         $zip->extractTo($dir, $filename);
         $store->moveIn($dir . DIRECTORY_SEPARATOR . $filename, $filename);
     }
     $zip->close();
     return true;
 }
Esempio n. 2
0
 /**
  * Fetch Archive Test
  *
  * The community fetchArchive version contains a cut down version of the device specs.
  * It has general_vendor, general_model, display_x, display_y, general_platform, general_platform_version,
  * general_browser, general_browser_version, general_app, general_app_version, general_language,
  * general_language_full, benahmark_min & benchmark_max
  *
  * @group community
  **/
 function test_ultimate_community_fetchArchive()
 {
     // Start tests with a clean slate
     $store = HandsetDetection\HDStore::getInstance();
     $store->purge();
     // Note : request storage dir to be created if it does not exist. (with TRUE as 2nd param)
     $hd = new HandsetDetection\HD4($this->ultimateConfig, true);
     $result = $hd->communityFetchArchive();
     $this->assertTrue($result);
     $data = $hd->getRawReply();
     echo "Downloaded " . strlen($data) . " bytes";
     $this->assertGreaterThan(9000000, strlen($data));
     // Filesize greater than 9Mb
 }
Esempio n. 3
0
// Query for some other information (remember the N95 headers are still set).
// Add detection options to query for additional reply information such as geoip information
// Note : We use the ipaddress to get the geoip location.
echo "<h1>Simple Detection - Passing a different ip address</h1><p>";
$hd->setDetectVar('ipaddress', '64.34.165.180');
if ($hd->siteDetect(array('options' => 'geoip,hd_specs'))) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}
echo "</p>";
// Ultimate customers can also download the ultimate database.
// Note  - Increase default timeout
echo "<h1>Archive Information</h1><p>";
$hd->setTimeout(500);
$time_start = _getmicrotime();
if ($hd->siteFetchArchive()) {
    $data = $hd->getRawReply();
    echo "Downloaded " . strlen($data) . " bytes";
} else {
    print $hd->getError();
}
$time_elapsed = _getmicrotime() - $time_start;
echo "<br/>Time elapsed " . $time_elapsed . "ms";
echo "</p>";
function _getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
Esempio n. 4
0
// Note : We use the ipaddress to get the geoip location.
echo "<h1>Simple Detection - Passing a different ip address</h1><p>";
$hd->setDetectVar('ipaddress', '64.34.165.180');
if ($hd->deviceDetect(array('options' => 'geoip,hd_specs'))) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}
echo "</p>";
// Ultimate customers can also download the ultimate database.
// Note  - Increase default timeout
echo "<h1>Archive Information</h1><p>";
$hd->setTimeout(500);
$time_start = _getmicrotime();
if ($hd->deviceFetchArchive()) {
    $data = $hd->getRawReply();
    echo "Downloaded " . strlen($data) . " bytes";
} else {
    print $hd->getError();
    print $hd->getRawReply();
    print "\n";
}
$time_elapsed = _getmicrotime() - $time_start;
echo "<br/>Time elapsed " . $time_elapsed . "ms";
echo "</p>";
function _getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
Esempio n. 5
0
 /**
  * Fetch Archive Test
  *
  * The community fetchArchive version contains a cut down version of the device specs.
  * It has general_vendor, general_model, display_x, display_y, general_platform, general_platform_version,
  * general_browser, general_browser_version, general_app, general_app_version, general_language,
  * general_language_full, benahmark_min & benchmark_max
  *
  * @group community
  **/
 function test_ultimate_community_fetchArchive()
 {
     $hd = new HandsetDetection\HD4($this->ultimateConfig);
     $hd->setTimeout(500);
     // Purge store
     $hd->Store->purge();
     // Fetch new device specs into store.
     $result = $hd->communityFetchArchive();
     $data = $hd->getRawReply();
     $size = strlen($data);
     echo "Downloaded {$size} bytes ";
     if ($size < 1000) {
         $this->markTestSkipped($data);
     } else {
         $this->assertTrue($result);
         $this->assertGreaterThan(9000000, strlen($data));
         // Filesize greater than 9Mb
     }
 }