Skip to content

Commit

Permalink
Merge pull request #2 from HydrefLab/1.0.0
Browse files Browse the repository at this point in the history
JediFaker tests and CI config
  • Loading branch information
golonix authored Jan 14, 2018
2 parents 768219c + ba872e8 commit 51c7752
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#CHANGELOG
#CHANGELOG

## 14-01-2017 - v1.0.0
* Initial version
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<a href="https://github.com/fzaninotto/Faker" target="_blank">Faker</a> extension for Star Wars junkie.
</p>

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

## Installation

```sh
Expand Down
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -16,10 +18,17 @@
"php": ">=7.1",
"fzaninotto/faker": "~1.4"
},
"require-dev": {
"phpunit/phpunit": "~6.0"
},
"autoload": {
"psr-4": {
"HydrefLab\\JediFaker\\": "src/"
}
},
"minimum-stability": "dev"
"autoload-dev": {
"psr-4": {
"HydrefLab\\JediFaker\\Test\\": "tests/"
}
}
}
10 changes: 10 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<phpunit bootstrap="./vendor/autoload.php" colors="true">
<testsuite name="Application Test Suite">
<directory>./tests</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">./tests/</directory>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 16 additions & 0 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace HydrefLab\JediFaker\Test;

use Faker\Generator;
use HydrefLab\JediFaker\Factory;
use PHPUnit\Framework\TestCase;

class FactoryTest extends TestCase
{
public function testFactoryReturnsFakerGenerator()
{
$faker = Factory::create();
$this->assertInstanceOf(Generator::class, $faker);
}
}
40 changes: 40 additions & 0 deletions tests/Provider/CharacterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace HydrefLab\JediFaker\Test;

use Faker\Generator;
use HydrefLab\JediFaker\Factory;
use PHPUnit\Framework\TestCase;

class CharacterTest extends TestCase
{
/**
* @var Generator
*/
protected $faker;

public function setUp()
{
$this->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);
}
}
15 changes: 15 additions & 0 deletions tests/Provider/DroidTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace HydrefLab\JediFaker\Test;

use HydrefLab\JediFaker\Factory;
use PHPUnit\Framework\TestCase;

class DroidTest extends TestCase
{
public function testDroidIsNotNull()
{
$faker = Factory::create();
$this->assertNotNull($faker->droid);
}
}
43 changes: 43 additions & 0 deletions tests/Provider/MovieTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace HydrefLab\JediFaker\Test;

use Faker\Generator;
use HydrefLab\JediFaker\Factory;
use PHPUnit\Framework\TestCase;

class MovieTest extends TestCase
{
/**
* @var Generator
*/
protected $faker;

public function setUp()
{
$this->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)
);
}
}
15 changes: 15 additions & 0 deletions tests/Provider/PlanetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace HydrefLab\JediFaker\Test;

use HydrefLab\JediFaker\Factory;
use PHPUnit\Framework\TestCase;

class PlanetTest extends TestCase
{
public function testDroidIsNotNull()
{
$faker = Factory::create();
$this->assertNotNull($faker->planet);
}
}
15 changes: 15 additions & 0 deletions tests/Provider/SpeciesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace HydrefLab\JediFaker\Test;

use HydrefLab\JediFaker\Factory;
use PHPUnit\Framework\TestCase;

class SpeciesTest extends TestCase
{
public function testDroidIsNotNull()
{
$faker = Factory::create();
$this->assertNotNull($faker->species);
}
}
15 changes: 15 additions & 0 deletions tests/Provider/VehicleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace HydrefLab\JediFaker\Test;

use HydrefLab\JediFaker\Factory;
use PHPUnit\Framework\TestCase;

class VehicleTest extends TestCase
{
public function testDroidIsNotNull()
{
$faker = Factory::create();
$this->assertNotNull($faker->vehicle);
}
}

0 comments on commit 51c7752

Please sign in to comment.