'IP address', 'City' => 'city', 'RegionName' => 'region', 'CountryName' => 'country' ); if (false !== $geoData) { $simplexml = new SimpleXMLElement($geoData); foreach ($keys as $key => $value) { printLine($counter, sprintf('Checking your %s (%s)', $keys[$key], $simplexml->$key), TEST_PASS); $counter ++; } } else { printLine($counter, 'Checking your geo data', TEST_FAIL); $failed = true; } // ----------------------------------------------------------------------------- $microtime = microtime(true); if (false !== file_get_contents(Zend_Service_LiveDocx_MailMerge::WSDL)) { $duration = microtime(true) - $microtime; $result = TEST_PASS; } else { $duration = -1; $result = TEST_FAIL; $failed = true; } printLine($counter, sprintf('Checking backend WSDL (%01.2fs)', $duration), $result); $counter ++; // ----------------------------------------------------------------------------- if (defined('DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD')) { $result = TEST_PASS; } else { $result = TEST_FAIL; $failed = true; } printLine($counter, 'Checking backend credentials are defined', $result); $counter ++; // ----------------------------------------------------------------------------- $errorMessage = null; try { $microtime = microtime(true); $mailMerge = new Zend_Service_LiveDocx_MailMerge( array ( 'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD ) ); $mailMerge->logIn(); $duration = microtime(true) - $microtime; } catch (Zend_Service_LiveDocx_Exception $e) { $duration = -1; $errorMessage = $e->getMessage(); } if (is_null($errorMessage)) { $result = TEST_PASS; } else { $result = TEST_FAIL; $failed = true; } printLine($counter, sprintf('Logging into backend service (%01.2fs)', $duration), $result); $counter ++; // ----------------------------------------------------------------------------- if (true === $failed) { $message = 'One or more tests failed. The web server environment, in which this script is running, does not meet the requirements for Zend_Service_LiveDocx_*.'; } else { $message = 'Congratulations! All tests passed. The server environment, in which this script is running, is suitable for Zend_Service_LiveDocx_*.'; } print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . $message . PHP_EOL . PHP_EOL)); // ----------------------------------------------------------------------------- /** * Print result line * * @param int $counter * @param string $testString * @param mixed $testResult * @return void */ function printLine($counter, $testString, $testResult) { $lineLength = Demos_Zend_Service_LiveDocx_Helper::LINE_LENGTH; // counter result $padding = $lineLength - (4 + strlen(TEST_PASS)); $counter = sprintf('%2s: ', $counter); $testString = str_pad($testString, $padding, '.', STR_PAD_RIGHT); printf('%s%s%s%s', $counter, $testString, $testResult, PHP_EOL); } // -----------------------------------------------------------------------------