protected function actionInfo() { $info = $this->wurfl->getWURFLInfo(); $config = WURFL_Configuration_ConfigHolder::getWURFLConfig(); $this->response['info'] = array('api' => 'PHP API', 'api_version' => WURFL_Constants::API_VERSION, 'mode' => 'high-' . $config->matchMode, 'wurfl_version' => $info->version, 'loaded_patches' => is_array($config->wurflPatches) ? implode(',', $config->wurflPatches) : '', 'platform' => 'PHP ' . PHP_VERSION, 'app_server' => $_SERVER['SERVER_SOFTWARE'], 'os' => php_uname()); $this->response['success'] = true; $this->sendResponse(); }
public function assertDevice(WURFL_CustomDevice $device, $response = null) { if ($this->operator != self::OPERATOR_EQUAL && $this->operator != self::OPERATOR_EQUAL_LOOSE) { if (self::compare($this->expected_id, $device->id, $this->operator)) { $this->details = "Logical match ({$this->operator}) succeeded"; return true; } else { $this->details = "Logical match failed: '{$this->expected_id} {$this->operator} {$device->id}'"; return false; } } if ($this->expected_id == $device->id) { $this->details = 'Exact match succeeded'; return true; } else { if ($this->exact_match === true) { $this->details = "Exact match required; expected:{$this->expected_id}, got:{$device->id}"; return false; } } $target_root_device = $device->getActualDeviceRootAncestor(); // No actual device root means no possible match if (!$target_root_device) { $this->details = "Exact match not required, but detected device ID has no actual_device_root ancestor; expected:{$this->expected_id}, got:{$device->id}"; return false; } // Perform loose comparison // Get reference device try { $reference_device = $this->wurflManager->getDevice($this->expected_id); $reference_root_device = $reference_device->getActualDeviceRootAncestor(); } catch (Exception $e) { throw new Exception("The expected WURFL ID ({$this->expected_id}) is not in the loaded WURFL Data! Detected as: {$device->id}", null, $e); } if ($reference_root_device->id != $target_root_device->id) { $this->details = "Loose match required; expected:{$this->expected_id}, got:{$device->id}"; return false; } return true; }
public function run(WURFL_WURFLManager $wurflManager) { $this->failure_count = 0; // Verify API Version if ($this->min_version && version_compare(WURFL_Constants::API_VERSION, $this->min_version, '<')) { throw new CentralTest_InvalidIntrospectorVersionException("Test requires WURFL PHP API >= {$this->min_version} (current " . WURFL_Constants::API_VERSION . ")"); } // Verify correct mode if ($this->mode != self::MODE_ALL) { $required_mode = $this->mode == self::MODE_HIGH_PERFORMANCE ? WURFL_Configuration_Config::MATCH_MODE_PERFORMANCE : WURFL_Configuration_Config::MATCH_MODE_ACCURACY; WURFL_Configuration_ConfigHolder::getWURFLConfig()->matchMode($required_mode); } $request_factory = new WURFL_Request_GenericRequestFactory(); $request = $request_factory->createRequest($this->http_headers, $this->ua_override); $device = $wurflManager->getDeviceForRequest($request); foreach ($this->assertions as $assertion) { /* @var $assertion CentralTestAssertion */ $assertion->wurflManager = $wurflManager; if (!$assertion->assert($device)) { $this->failure_count++; } } return $this->failure_count === 0; }