From e29f4d7c558ca6bff88dbadabee68276a64beabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sun, 14 Jan 2018 20:21:57 +0100 Subject: [PATCH 1/6] Update composer.json --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3e9a8c3..5f57157 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,8 @@ { "name": "hydreflab/jedi-faker", + "type": "library", "description": "Faker extension for Star Wars junkie", + "keywords": ["faker", "faker-extension", "fixtures", "data", "star-wars"], "license": "MIT", "support": { "issues": "https://github.com/HydrefLab/jedi-faker/issues", @@ -20,6 +22,5 @@ "psr-4": { "HydrefLab\\JediFaker\\": "src/" } - }, - "minimum-stability": "dev" + } } From 4bfa3088748c98a251f1487d8234b89d15c90d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sun, 14 Jan 2018 20:22:37 +0100 Subject: [PATCH 2/6] Fix Factory compatibility with Faker one --- src/Factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Factory.php b/src/Factory.php index 82d281e..7bab5e9 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -18,7 +18,7 @@ class Factory extends FakerFactory * @param string $locale * @return Generator */ - public static function create(string $locale = self::DEFAULT_LOCALE): Generator + public static function create($locale = self::DEFAULT_LOCALE): Generator { $generator = parent::create($locale); From 5c15497cb45c347a79972f814bcd7dafba8695e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sun, 14 Jan 2018 20:33:04 +0100 Subject: [PATCH 3/6] Add phpunit configuration --- composer.json | 3 +++ phpunit.xml | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 phpunit.xml diff --git a/composer.json b/composer.json index 5f57157..3afeaf8 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,9 @@ "php": ">=7.1", "fzaninotto/faker": "~1.4" }, + "require-dev": { + "phpunit/phpunit": "~6.0" + }, "autoload": { "psr-4": { "HydrefLab\\JediFaker\\": "src/" diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..1df7aaa --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,10 @@ + + + ./tests + + + + ./tests/ + + + From c84ddce09c6fd8ccd9f5c2e31f5da4531b6e298e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sun, 14 Jan 2018 20:55:22 +0100 Subject: [PATCH 4/6] Add tests --- composer.json | 5 ++++ tests/FactoryTest.php | 16 ++++++++++++ tests/Provider/CharacterTest.php | 40 +++++++++++++++++++++++++++++ tests/Provider/DroidTest.php | 15 +++++++++++ tests/Provider/MovieTest.php | 43 ++++++++++++++++++++++++++++++++ tests/Provider/PlanetTest.php | 15 +++++++++++ tests/Provider/SpeciesTest.php | 15 +++++++++++ tests/Provider/VehicleTest.php | 15 +++++++++++ 8 files changed, 164 insertions(+) create mode 100644 tests/FactoryTest.php create mode 100644 tests/Provider/CharacterTest.php create mode 100644 tests/Provider/DroidTest.php create mode 100644 tests/Provider/MovieTest.php create mode 100644 tests/Provider/PlanetTest.php create mode 100644 tests/Provider/SpeciesTest.php create mode 100644 tests/Provider/VehicleTest.php diff --git a/composer.json b/composer.json index 3afeaf8..219256b 100644 --- a/composer.json +++ b/composer.json @@ -25,5 +25,10 @@ "psr-4": { "HydrefLab\\JediFaker\\": "src/" } + }, + "autoload-dev": { + "psr-4": { + "HydrefLab\\JediFaker\\Test\\": "tests/" + } } } diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php new file mode 100644 index 0000000..201a277 --- /dev/null +++ b/tests/FactoryTest.php @@ -0,0 +1,16 @@ +assertInstanceOf(Generator::class, $faker); + } +} diff --git a/tests/Provider/CharacterTest.php b/tests/Provider/CharacterTest.php new file mode 100644 index 0000000..72e981e --- /dev/null +++ b/tests/Provider/CharacterTest.php @@ -0,0 +1,40 @@ +faker = Factory::create(); + } + + public function testLightSideIsNotNull() + { + $this->assertNotNull($this->faker->lightSide); + } + + public function testDarkSideIsNotNull() + { + $this->assertNotNull($this->faker->darkSide); + } + + public function testCharacterIsNotNull() + { + $this->assertNotNull($this->faker->character); + } + + public function testQuotesNotNull() + { + $this->assertNotNull($this->faker->quote); + } +} diff --git a/tests/Provider/DroidTest.php b/tests/Provider/DroidTest.php new file mode 100644 index 0000000..72b58bc --- /dev/null +++ b/tests/Provider/DroidTest.php @@ -0,0 +1,15 @@ +assertNotNull($faker->droid); + } +} diff --git a/tests/Provider/MovieTest.php b/tests/Provider/MovieTest.php new file mode 100644 index 0000000..39d1e51 --- /dev/null +++ b/tests/Provider/MovieTest.php @@ -0,0 +1,43 @@ +faker = Factory::create(); + } + + public function testEpisodeIsNotNull() + { + $this->assertNotNull($this->faker->episode); + } + + public function testEpisodeReturnsFirstEpisodeTitle() + { + $this->assertEquals('Episode I: The Phantom Menace', $this->faker->episode(1)); + } + + public function testEpisodeOpeningCrawlIsNotNull() + { + $this->assertNotNull($this->faker->episodeOpeningCrawl); + } + + public function testEpisodeOpeningCrawlReturnsFirstEpisodeCrawl() + { + $this->assertEquals( + "Turmoil has engulfed the\r\nGalactic Republic. The taxation\r\nof trade routes to outlying star\r\nsystems is in dispute.\r\n\r\nHoping to resolve the matter\r\nwith a blockade of deadly\r\nbattleships, the greedy Trade\r\nFederation has stopped all\r\nshipping to the small planet\r\nof Naboo.\r\n\r\nWhile the Congress of the\r\nRepublic endlessly debates\r\nthis alarming chain of events,\r\nthe Supreme Chancellor has\r\nsecretly dispatched two Jedi\r\nKnights, the guardians of\r\npeace and justice in the\r\ngalaxy, to settle the conflict....", + $this->faker->episodeOpeningCrawl(1) + ); + } +} diff --git a/tests/Provider/PlanetTest.php b/tests/Provider/PlanetTest.php new file mode 100644 index 0000000..d23cbef --- /dev/null +++ b/tests/Provider/PlanetTest.php @@ -0,0 +1,15 @@ +assertNotNull($faker->planet); + } +} diff --git a/tests/Provider/SpeciesTest.php b/tests/Provider/SpeciesTest.php new file mode 100644 index 0000000..92adca5 --- /dev/null +++ b/tests/Provider/SpeciesTest.php @@ -0,0 +1,15 @@ +assertNotNull($faker->species); + } +} diff --git a/tests/Provider/VehicleTest.php b/tests/Provider/VehicleTest.php new file mode 100644 index 0000000..1afec58 --- /dev/null +++ b/tests/Provider/VehicleTest.php @@ -0,0 +1,15 @@ +assertNotNull($faker->vehicle); + } +} From 457fd275a23784f1c2683a764c7990d193c7d4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sun, 14 Jan 2018 21:00:03 +0100 Subject: [PATCH 5/6] Add Travis CI config --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d28767f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: php + +php: + - 7.1 + - 7.2 + +before_script: + - curl -s http://getcomposer.org/installer | php + - php composer.phar install --dev --prefer-source + +script: + - php vendor/bin/phpunit \ No newline at end of file From ba872e872f3e406ec0362cd0df67e88e974fb4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sun, 14 Jan 2018 21:15:54 +0100 Subject: [PATCH 6/6] Add Travis CI badge, update changelog --- CHANGELOG.md | 5 ++++- README.md | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5002868..9e4f9a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,4 @@ -#CHANGELOG \ No newline at end of file +#CHANGELOG + +## 14-01-2017 - v1.0.0 +* Initial version \ No newline at end of file diff --git a/README.md b/README.md index 55901de..c6b3b56 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Faker extension for Star Wars junkie.

+[![Build Status](https://travis-ci.org/HydrefLab/jedi-faker.svg?branch=master)](https://travis-ci.org/HydrefLab/jedi-faker) + ## Installation ```sh