summaryrefslogtreecommitdiffstats
path: root/test/PJsonCurlTest.php
diff options
context:
space:
mode:
authorMateusz Jaworski <niespammnie@gmail.com>2014-07-15 09:51:56 +0200
committerMateusz Jaworski <niespammnie@gmail.com>2014-07-15 09:51:56 +0200
commit2ebe98e90e172b2c824f4263b9367346392227c5 (patch)
treeb9a284b086b69e057386e11333d7ff15a130834d /test/PJsonCurlTest.php
parent0e0aa739ec43eb6146bd483b0edd12b5928d93ee (diff)
parent090e64bd20a40ed55c79025e611ba2c6a45c80df (diff)
downloadphp.curl-2ebe98e90e172b2c824f4263b9367346392227c5.zip
php.curl-2ebe98e90e172b2c824f4263b9367346392227c5.tar.gz
php.curl-2ebe98e90e172b2c824f4263b9367346392227c5.tar.bz2
Merge pull request #1 from theres/master
PCurlResponse with body & headers
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