From 23973c64318d4211a7d09a83a85fc2c662027779 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 17 Dec 2010 08:49:56 +0100 Subject: [PATCH] add support for disconnected state in index_wstatus1 --- Wrt3g/HtmlParser.php | 10 +++++++--- tests/index_wstatus1-aquiring.phpt | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Wrt3g/HtmlParser.php b/Wrt3g/HtmlParser.php index ac4db35..d420f4d 100644 --- a/Wrt3g/HtmlParser.php +++ b/Wrt3g/HtmlParser.php @@ -33,13 +33,14 @@ class Wrt3g_HtmlParser /** * Parses the body of /index_wstatus1.asp and returns extracted values. + * If no connection is established, the values are NULL. * * @param string $body HTML document to parse * * @return array Array of key-value pairs, probably with - * - "type" - * - "network" - * - "signal strength" + * - "type" - i.e. "GPRS" + * - "network" - Carrier network name, i.e. "BASE DE" + * - "signal strength" - good, excellent, poor */ public function index_wstatus1($body) { @@ -82,6 +83,9 @@ class Wrt3g_HtmlParser if (isset(self::$arTranslations[$value])) { $value = self::$arTranslations[$value]; } + if ($value == 'aquiring') { + $value = null; + } $arRetval[$key] = $value; next($arMatches); } diff --git a/tests/index_wstatus1-aquiring.phpt b/tests/index_wstatus1-aquiring.phpt index 1435fcd..6efd48a 100644 --- a/tests/index_wstatus1-aquiring.phpt +++ b/tests/index_wstatus1-aquiring.phpt @@ -1,5 +1,5 @@ --TEST-- -test Wrt3g_HtmlParser::index_wstatus1() when aquiring +test Wrt3g_HtmlParser::index_wstatus1() when we have no connection --FILE-- - string(8) "aquiring" + NULL ["network"]=> - string(8) "aquiring" + NULL ["signal strength"]=> - string(8) "aquiring" + NULL } -- 2.30.2