From f96b0c0afe912224ba9ad76b56c66ab4c3f53ce0 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 18 Oct 2015 14:46:07 +0200 Subject: [PATCH] adding unit tests for all JSON-LD cases --- tst/jsonApi.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/tst/jsonApi.php b/tst/jsonApi.php index 63fc177..59cfb15 100644 --- a/tst/jsonApi.php +++ b/tst/jsonApi.php @@ -175,7 +175,68 @@ class jsonApiTest extends PHPUnit_Framework_TestCase ob_start(); new zerobin; $content = ob_get_contents(); - $this->assertEquals(file_get_contents(PUBLIC_PATH . '/js/paste.jsonld'), $content, 'outputs data correctly'); + $this->assertEquals(str_replace( + '?jsonld=', + '/?jsonld=', + file_get_contents(PUBLIC_PATH . '/js/paste.jsonld') + ), $content, 'outputs data correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testJsonLdComment() + { + $this->reset(); + $paste = helper::getPasteWithAttachment(); + $this->_model->create(helper::getPasteId(), $paste); + $_GET['jsonld'] = 'comment'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertEquals(str_replace( + '?jsonld=', + '/?jsonld=', + file_get_contents(PUBLIC_PATH . '/js/comment.jsonld') + ), $content, 'outputs data correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testJsonLdPasteMeta() + { + $this->reset(); + $paste = helper::getPasteWithAttachment(); + $this->_model->create(helper::getPasteId(), $paste); + $_GET['jsonld'] = 'pastemeta'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertEquals(str_replace( + '?jsonld=', + '/?jsonld=', + file_get_contents(PUBLIC_PATH . '/js/pastemeta.jsonld') + ), $content, 'outputs data correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testJsonLdCommentMeta() + { + $this->reset(); + $paste = helper::getPasteWithAttachment(); + $this->_model->create(helper::getPasteId(), $paste); + $_GET['jsonld'] = 'commentmeta'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertEquals(str_replace( + '?jsonld=', + '/?jsonld=', + file_get_contents(PUBLIC_PATH . '/js/commentmeta.jsonld') + ), $content, 'outputs data correctly'); } /**