From 85ef10149ecef7533e123a4127601e0948f6e619 Mon Sep 17 00:00:00 2001 From: Andre Wyrwa Date: Tue, 6 Dec 2016 09:45:19 +1100 Subject: [PATCH] add JsonParser --- src/Parser/JsonParser.php | 31 + tests/Support/TestsFixtures/country.json | 1486 +++++++++++++++++ .../Fixtures/Parser/JsonParserTest.php | 37 + .../Fixtures/Parser/MasterParserTest.php | 2 +- .../Fixtures/Parser/XmlParserTest.php | 14 +- .../Fixtures/Parser/YamlParserTest.php | 12 +- 6 files changed, 1576 insertions(+), 6 deletions(-) create mode 100644 src/Parser/JsonParser.php create mode 100644 tests/Support/TestsFixtures/country.json create mode 100644 tests/TheIconic/Fixtures/Parser/JsonParserTest.php diff --git a/src/Parser/JsonParser.php b/src/Parser/JsonParser.php new file mode 100644 index 0000000..e15addb --- /dev/null +++ b/src/Parser/JsonParser.php @@ -0,0 +1,31 @@ +parserInstance = new JsonParser(); + } + + /** + * + */ + public function testParse() + { + $fixtureFile = self::TESTS_FIXTURES_DIRECTORY . 'country.json'; + + $fixture = $this->parserInstance->parse($fixtureFile); + + $this->assertCount(247, $fixture); + $this->assertEquals('country', $fixture->getName()); + $this->assertInstanceOf('TheIconic\Fixtures\Fixture\Fixture', $fixture); + } +} diff --git a/tests/TheIconic/Fixtures/Parser/MasterParserTest.php b/tests/TheIconic/Fixtures/Parser/MasterParserTest.php index 2b553db..3f1ceac 100644 --- a/tests/TheIconic/Fixtures/Parser/MasterParserTest.php +++ b/tests/TheIconic/Fixtures/Parser/MasterParserTest.php @@ -10,7 +10,7 @@ class MasterParserTest extends \PHPUnit_Framework_TestCase const TESTS_FIXTURES_DIRECTORY = './tests/Support/TestsFixtures/'; - const CURRENT_NUMBER_OF_PARSERS = 2; + const CURRENT_NUMBER_OF_PARSERS = 3; /** * @var MasterParser diff --git a/tests/TheIconic/Fixtures/Parser/XmlParserTest.php b/tests/TheIconic/Fixtures/Parser/XmlParserTest.php index 1644ba3..7188c8d 100644 --- a/tests/TheIconic/Fixtures/Parser/XmlParserTest.php +++ b/tests/TheIconic/Fixtures/Parser/XmlParserTest.php @@ -2,7 +2,9 @@ namespace TheIconic\Fixtures\Parser; -class XmlParserTest extends \PHPUnit_Framework_TestCase +use PHPUnit_Framework_TestCase; + +class XmlParserTest extends PHPUnit_Framework_TestCase { const TESTS_FIXTURES_DIRECTORY = './tests/Support/TestsFixtures/'; @@ -11,12 +13,18 @@ class XmlParserTest extends \PHPUnit_Framework_TestCase */ private $parserInstance; + /** + * + */ public function setUp() { $this->parserInstance = new XmlParser(); } - public function testXmlParser() + /** + * + */ + public function testParse() { $fixtureFile = self::TESTS_FIXTURES_DIRECTORY . 'customer_address_region_suburb.xml'; @@ -30,7 +38,7 @@ public function testXmlParser() /** * @expectedException \TheIconic\Fixtures\Exception\InvalidParserException */ - public function testXmlParserException() + public function testParseException() { $fixtureFile = self::TESTS_FIXTURES_DIRECTORY . 'currency_conversion_damage.xml'; diff --git a/tests/TheIconic/Fixtures/Parser/YamlParserTest.php b/tests/TheIconic/Fixtures/Parser/YamlParserTest.php index 64f6f74..2807e92 100644 --- a/tests/TheIconic/Fixtures/Parser/YamlParserTest.php +++ b/tests/TheIconic/Fixtures/Parser/YamlParserTest.php @@ -2,7 +2,9 @@ namespace TheIconic\Fixtures\Parser; -class YamlParserTest extends \PHPUnit_Framework_TestCase +use PHPUnit_Framework_TestCase; + +class YamlParserTest extends PHPUnit_Framework_TestCase { const TESTS_FIXTURES_DIRECTORY = './tests/Support/TestsFixtures/'; @@ -11,12 +13,18 @@ class YamlParserTest extends \PHPUnit_Framework_TestCase */ private $parserInstance; + /** + * + */ public function setUp() { $this->parserInstance = new YamlParser(); } - public function testYamlParser() + /** + * + */ + public function testParse() { $fixtureFile = self::TESTS_FIXTURES_DIRECTORY . 'country.yml';