diff options
Diffstat (limited to 'test/Json/PJsonCurlTest.php')
-rw-r--r-- | test/Json/PJsonCurlTest.php | 35 |
1 files changed, 35 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(''); + } + +} |