diff --git a/tests/basic.phpt b/tests/basic.phpt new file mode 100644 index 0000000000000000000000000000000000000000..96ded63ede61e1c56e4c13a2675eb157241469bc --- /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 0000000000000000000000000000000000000000..a940580cc457780db1666bb0de5dbf06f8b5ed2e --- /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 0000000000000000000000000000000000000000..922e206a14aeb0669ed9a858f9b9d227d1762861 --- /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 0000000000000000000000000000000000000000..b888c4acdb52157986e6b62d8bf92934fd53ddb9 --- /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 8905ef80669b7a1a68e2a56edf4ebde3fa05c06e..5c1f65f07de0d2cd8df9433b94bf9d12eeb84fad 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) {}