diff options
author | purplecode <niespammnie@gmail.com> | 2014-12-24 12:42:42 +0100 |
---|---|---|
committer | purplecode <niespammnie@gmail.com> | 2014-12-24 12:42:42 +0100 |
commit | fd0f39cb224de007e6135c9e08cc9429c7b5a9dc (patch) | |
tree | 5be12b850255ccd8a61571e0e83c6bc6c5d2c8d9 /test/Json | |
parent | 5b74984770c4228808138231c9580d22f7282475 (diff) | |
download | php.curl-fd0f39cb224de007e6135c9e08cc9429c7b5a9dc.zip php.curl-fd0f39cb224de007e6135c9e08cc9429c7b5a9dc.tar.gz php.curl-fd0f39cb224de007e6135c9e08cc9429c7b5a9dc.tar.bz2 |
tests repackage
Diffstat (limited to 'test/Json')
-rw-r--r-- | test/Json/PJsonCurlTest.php | 35 | ||||
-rw-r--r-- | test/Json/test.json | 1 | ||||
-rw-r--r-- | test/Json/testInvalid.json | 1 |
3 files changed, 37 insertions, 0 deletions
diff --git a/test/Json/PJsonCurlTest.php b/test/Json/PJsonCurlTest.php new file mode 100644 index 0000000..707fa10 --- /dev/null +++ b/test/Json/PJsonCurlTest.php @@ -0,0 +1,35 @@ +<?php + +require_once (dirname(__FILE__) . '/../../src/PurpleCode/PCurl/PCurlResponse.php'); +require_once (dirname(__FILE__) . '/../../src/PurpleCode/PCurl/Json/PJsonCurlResponse.php'); +require_once (dirname(__FILE__) . '/../../src/PurpleCode/PCurl/PCurl.php'); +require_once (dirname(__FILE__) . '/../../src/PurpleCode/PCurl/Json/PJsonCurl.php'); + +use PurpleCode\PCurl\Json\PJsonCurl; + +class PJsonCurlTest extends PHPUnit_Framework_TestCase { + + public function testShouldGetJsonFileAndParse() { + // given + $cut = new PJsonCurl('file:///' . __DIR__ . '/test.json'); + + // when + $response = $cut->get(''); + + // then + $this->assertEquals(2, $response->getJson()->a->b); + $this->assertEquals("a", $response->getJson()->a->c); + } + + public function testShouldFailParseWrongFile() { + // given + $cut = new PJsonCurl('file:///' . __DIR__ . '/testinvalid.json'); + + //then + $this->setExpectedException('PurpleCode\PCurl\PCurlException'); + + // when + $response = $cut->get(''); + } + +} diff --git a/test/Json/test.json b/test/Json/test.json new file mode 100644 index 0000000..bb4ed6f --- /dev/null +++ b/test/Json/test.json @@ -0,0 +1 @@ +{"a":{"b":2,"c":"a"}}
\ No newline at end of file diff --git a/test/Json/testInvalid.json b/test/Json/testInvalid.json new file mode 100644 index 0000000..1a5125f --- /dev/null +++ b/test/Json/testInvalid.json @@ -0,0 +1 @@ +{"a":3
\ No newline at end of file |