From 8b778852d166787b190902379b5868f323b7c98d Mon Sep 17 00:00:00 2001 From: Kevin Abel <kevin.abel.0@gmail.com> Date: Mon, 8 Sep 2014 13:03:26 -0500 Subject: [PATCH] A PHPT integration tests Tests that the RAVE RSS feed is working and that a point-in-time example can be translated into CAP XML. --- tests/basic.phpt | 11 +++++++++++ tests/config.inc.php | 16 ++++++++++++++++ tests/data/rave.xml | 19 +++++++++++++++++++ tests/rave.phpt | 9 +++++++++ www/json/unlcap.js | 2 +- 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/basic.phpt create mode 100644 tests/config.inc.php create mode 100644 tests/data/rave.xml create mode 100644 tests/rave.phpt diff --git a/tests/basic.phpt b/tests/basic.phpt new file mode 100644 index 0000000..96ded63 --- /dev/null +++ b/tests/basic.phpt @@ -0,0 +1,11 @@ +--TEST-- +Basic RSS feed parsing, recent checking, and output +--FILE-- +<?php +require_once dirname(__FILE__).'/config.inc.php'; +require_once dirname(__FILE__).'/../scripts/functions.inc.php'; +$outputObject = getCAPData($config); +echo $outputObject->toXML('alert', 'urn:oasis:names:tc:emergency:cap:1.2'); +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<alert xmlns="urn:oasis:names:tc:emergency:cap:1.2"><identifier>044972ad186d3901e0079ed73c54653d</identifier><sender>police.unl.edu</sender><sent>2014-06-10T19:17:39+00:00</sent><status>Test</status><msgType>Alert</msgType><scope>Public</scope><note>This is only a test</note><info><category>Safety</category><event>UNL Alert</event><ugency>Immediate</ugency><severity>Extreme</severity><certainty>Observed</certainty><headline>Mark Only Test</headline><description>UNL Alert: this is a test</description><web>http://www.unl.edu/</web></info></alert> diff --git a/tests/config.inc.php b/tests/config.inc.php new file mode 100644 index 0000000..a940580 --- /dev/null +++ b/tests/config.inc.php @@ -0,0 +1,16 @@ +<?php + +function autoload($class) +{ + $class = str_replace(array('_', '\\'), '/', $class); + include $class . '.php'; +} + +spl_autoload_register('autoload'); + +set_include_path(__DIR__ . '/../src' ); + +$config = array( + 'proxyUrl' => __DIR__ . '/data/rave.xml', + 'recentTimeframe' => '2014-06-10T18:47:39Z', +); diff --git a/tests/data/rave.xml b/tests/data/rave.xml new file mode 100644 index 0000000..922e206 --- /dev/null +++ b/tests/data/rave.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"> + <channel> + <title>UNL Alert UCOMM</title> + <link>http://www.getrave.com/rss/unl/channel1</link> + <description>UNL Alert RSS</description> + <category>Alerts</category> + <dc:subject>Alerts</dc:subject> + <item> + <title>Mark Only Test</title> + <link /> + <description>UNL Alert: this is a test</description> + <category>Alerts</category> + <pubDate>Tue, 10 Jun 2014 19:17:39 GMT</pubDate> + <guid /> + <dc:date>2014-06-10T19:17:39Z</dc:date> + </item> + </channel> +</rss> diff --git a/tests/rave.phpt b/tests/rave.phpt new file mode 100644 index 0000000..b888c4a --- /dev/null +++ b/tests/rave.phpt @@ -0,0 +1,9 @@ +--TEST-- +Live RSS feed from vendor +--FILE-- +<?php +require_once dirname(__FILE__).'/config.inc.php'; +$alerts = new UNL_Alert_RaveRSS('http://www.getrave.com/rss/unl/channel1'); +echo "DONE"; +--EXPECT-- +DONE diff --git a/www/json/unlcap.js b/www/json/unlcap.js index 8905ef8..5c1f65f 100644 --- a/www/json/unlcap.js +++ b/www/json/unlcap.js @@ -1,4 +1,4 @@ -unlAlerts.data = {} +unlAlerts.data = {}; try { unlAlerts.server.init(); } catch(e) {} -- GitLab