summaryrefslogtreecommitdiffstats
path: root/test/PJsonCurlTest.php
diff options
context:
space:
mode:
authortheres <dmarkiew@CNU3429M9W.nsn-intra.net>2014-07-15 09:44:07 +0200
committertheres <dmarkiew@CNU3429M9W.nsn-intra.net>2014-07-15 09:44:07 +0200
commit090e64bd20a40ed55c79025e611ba2c6a45c80df (patch)
treeb9a284b086b69e057386e11333d7ff15a130834d /test/PJsonCurlTest.php
parent1884e50d534f9ca82527d06861cb7064fe1d9b40 (diff)
downloadphp.curl-090e64bd20a40ed55c79025e611ba2c6a45c80df.zip
php.curl-090e64bd20a40ed55c79025e611ba2c6a45c80df.tar.gz
php.curl-090e64bd20a40ed55c79025e611ba2c6a45c80df.tar.bz2
PCurl will now return PCurlResponse object instead of raw body. PJsonCurl
also, but will try to parse JSON and throw an exception when fail to parse.
Diffstat (limited to 'test/PJsonCurlTest.php')
-rw-r--r--test/PJsonCurlTest.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/PJsonCurlTest.php b/test/PJsonCurlTest.php
new file mode 100644
index 0000000..8aec5b8
--- /dev/null
+++ b/test/PJsonCurlTest.php
@@ -0,0 +1,39 @@
+<?php
+
+
+require_once (dirname(__FILE__) . '/../src/PurpleCode/PCurl/PCurlResponse.php');
+require_once (dirname(__FILE__) . '/../src/PurpleCode/PCurl/PCurlJsonResponse.php');
+require_once (dirname(__FILE__) . '/../src/PurpleCode/PCurl/PCurl.php');
+require_once (dirname(__FILE__) . '/../src/PurpleCode/PCurl/PJsonCurl.php');
+
+use PurpleCode\PCurl\PJsonCurl;
+
+class PCurlTest extends PHPUnit_Framework_TestCase {
+
+ private function getCACertBundlePath() {
+ return __DIR__.'\ca-cert.crt';
+ }
+
+ public function testShouldGetJsonFileAndParse() {
+ // given
+ $cut = new PJsonCurl('file://test.json');
+
+ // when
+ $response = $cut->get('');
+
+ // then
+ $this->assertEquals(2, $response->getBody()->a->b);
+ $this->assertEquals("a", $response->getBody()->a->c);
+ }
+
+ public function testShouldFailParseWrongFile() {
+ // given
+ $cut = new PJsonCurl('file://testInvaliud.json');
+
+ //then
+ $this->setExpectedException('PurpleCode\PCurl\PCurlException');
+
+ // when
+ $response = $cut->get('');
+ }
+} \ No newline at end of file