diff --git a/test/OPDSTest.php b/test/OPDSTest.php index 8c88894..55b40b0 100644 --- a/test/OPDSTest.php +++ b/test/OPDSTest.php @@ -11,6 +11,7 @@ require_once (dirname(__FILE__) . "/../book.php"); require_once (dirname(__FILE__) . "/../OPDS_renderer.php"); define ("OPDS_RELAX_NG", dirname(__FILE__) . "/opds-relax-ng/opds_catalog_1_1.rng"); +define ("OPENSEARCHDESCRIPTION_RELAX_NG", dirname(__FILE__) . "/opds-relax-ng/opensearchdescription.rng"); define ("JING_JAR", dirname(__FILE__) . "/jing.jar"); define ("TEST_FEED", dirname(__FILE__) . "/text.atom"); @@ -24,13 +25,13 @@ class OpdsTest extends PHPUnit_Framework_TestCase unlink (TEST_FEED); } - function opdsValidateSchema($feed) { + function opdsValidateSchema($feed, $relax = OPDS_RELAX_NG) { $path = ""; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { // huge hack, not proud about it $path = "c:\\Progra~1\\Java\\jre7\\bin\\"; } - $res = system($path . 'java -jar ' . JING_JAR . ' ' . OPDS_RELAX_NG . ' ' . $feed); + $res = system($path . 'java -jar ' . JING_JAR . ' ' . $relax . ' ' . $feed); if ($res != '') { echo 'RelaxNG validation error: '.$res; return false; @@ -63,6 +64,18 @@ class OpdsTest extends PHPUnit_Framework_TestCase $_SERVER['QUERY_STRING'] = NULL; } + + public function testOpenSearchDescription () + { + $_SERVER['QUERY_STRING'] = ""; + + $OPDSRender = new OPDSRenderer (); + + file_put_contents (TEST_FEED, $OPDSRender->getOpenSearch ()); + $this->AssertTrue ($this->opdsValidateSchema (TEST_FEED, OPENSEARCHDESCRIPTION_RELAX_NG)); + + $_SERVER['QUERY_STRING'] = NULL; + } public function testPageIndexMultipleDatabase () { diff --git a/test/opds-relax-ng/opensearchdescription.rng b/test/opds-relax-ng/opensearchdescription.rng new file mode 100644 index 0000000..7b71ada --- /dev/null +++ b/test/opds-relax-ng/opensearchdescription.rng @@ -0,0 +1,416 @@ + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + get + post + GET + POST + + + + + + + + get + post + GET + POST + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 256 + + + + + + + + 48 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 256 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 64 + + + + + + + + 256 + + + + + + + + open + limited + private + closed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +