static function setUpBeforeClass()
 {
     $hd4 = new HandsetDetection\HD4('hd4UltimateConfig.php');
     echo "Fetching Archive-";
     $hd4->communityFetchArchive();
     echo "Done";
     return true;
 }
Example #2
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;
 }
Example #3
0
$configFile = "../hd4UltimateConfig.php";
$dataFile = "benchmarkData.txt";
// Ensure config file present.
if (!file_exists($configFile)) {
    die('Config file not found');
}
// Ensure data file present
if (!file_exists($dataFile)) {
    die('Data file not found');
}
include $configFile;
if (@$hdconfig['username'] == "your_api_username") {
    die('Please configure your username, secret and site_id');
}
// Create a new detection object
$hd = new HandsetDetection\HD4($configFile);
// fetch the archive if it does not exist
if (!file_exists('/tmp/hd40store/user-agent0.json')) {
    $hd->deviceFetchArchive();
}
class FileException extends Exception
{
}
class Benchmark
{
    private $file;
    private $time_start;
    private $time;
    private $headers;
    var $count = 0;
    private $verbose = true;
Example #4
0
 /**
  * Windows Phone Native Nokia Lumia 1020
  * @depends test_ultimate_community_fetchArchive
  * @group community
  **/
 function test_ultimate_community_deviceDetectWindowsPhone()
 {
     $buildInfo = array('devicemanufacturer' => 'nokia', 'devicename' => 'RM-875');
     $hd = new HandsetDetection\HD4($this->ultimateConfig);
     $result = $hd->deviceDetect($buildInfo);
     $reply = $hd->getReply();
     $this->assertEquals('Nokia', $reply['hd_specs']['general_vendor']);
     $this->assertEquals('Lumia 1020', $reply['hd_specs']['general_model']);
     $this->assertEquals('Windows Phone', $reply['hd_specs']['general_platform']);
     $this->assertEquals('', $reply['hd_specs']['general_type']);
     $this->assertEquals(0, $reply['hd_specs']['display_ppi']);
 }
Example #5
0
ini_set('display_errors', 1);
ini_set('max_execution_time', 120);
ini_set('memory_limit', "512M");
error_reporting(E_ALL);
//$configFile = 'hdconfig.php';
$configFile = 'hd4UltimateConfig.php';
// Ensure config file is setup.
if (!file_exists($configFile)) {
    die('Config file not found');
}
include $configFile;
if (@$hdconfig['username'] == "your_api_username") {
    die('Please configure your username, secret and site_id');
}
require_once 'HD4.php';
$hd = new HandsetDetection\HD4($configFile);
/*
/// Vendors example : Get a list of all vendors
echo "<h1>Vendors</h1><p>";
if ($hd->deviceVendors()) {
	$data = $hd->getReply();
	print_r($data);
} else {
	print $hd->getError();
}
echo "</p>";

// Models example : Get a list of all models for a specific vendor
echo "<h1>Nokia Models</h1><p>";
if ($hd->deviceModels('Nokia')) {
	$data = $hd->getReply();