Skip to content

Commit

Permalink
Merge pull request #17 from HydrefLab/1.2
Browse files Browse the repository at this point in the history
Update to v1.2
  • Loading branch information
golonix authored Jan 23, 2018
2 parents 1307524 + 125695d commit b3405cd
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 21 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
* Decreased required PHP version

### Fixed
* Fixed `IGG-88` droid name
* Fixed `IGG-88` droid name

## v1.2.0 (23-01-2018)

### Added
* Added new characters, droids, planets and species from Episode VII and Episode VIII
* Added new squadron formatter
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ $faker->species; // Wookiee
$faker->vehicle; // Millennium Falcon
```
### `HydrefLab\JediFaker\Provider\Squadron`
```
$faker->squadron; // Green
$faker->squadronName; // Blue Squadron
$faker->pilot; // Red Leader or Blue #7
$faker->pilotRank; // Pilot
```
## Contributing
Contributions are welcome! Please, read [CONTRIBUTING][] for details.
Expand Down
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Factory extends FakerFactory
* @var array
*/
protected static $jediProviders = [
'Character', 'Droid', 'Movie', 'Planet', 'Species', 'Vehicle',
'Character', 'Droid', 'Movie', 'Planet', 'Species', 'Squadron', 'Vehicle',
];

/**
Expand Down
40 changes: 25 additions & 15 deletions src/Provider/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Character extends Base
*/
protected static $darkSide = [
'Darth Maul', 'Darth Sidious', 'Darth Vader', 'Dooku',
'Grievous',
'Kylo Ren',
'Snoke',
];
Expand Down Expand Up @@ -39,23 +40,32 @@ class Character extends Base
* @var array
*/
protected static $characters = [
'Amilyn Holdo',
'Bail Prestor Organa', 'Boba Fett', 'Bossk', 'Bren Derlin',
'C-3PO', 'Captain Phasma', 'Chewbacca', 'Crix Madine',
'Amilyn Holdo', 'Armitage Hux', 'Athgar Heece',
'Bail Prestor Organa', 'Bala-Tik', 'Bazine Netal', 'Boba Fett', 'Bobbajo', 'Bollie Prindel', 'Bossk',
'Bren Derlin',
'C\'ai Threnalli', 'C-3PO', 'Caluan Ematt', 'Chewbacca', 'Cratinus', 'Crix Madine', 'Crokind Shand', 'Crusher Roodown',
'Datoo', 'DJ', 'Dopheld Mitaka',
'Edrison Peavey', 'Ello Asty',
'Finis Valorum', 'Finn', 'Firmus Piett',
'Gial Ackbar', 'Grievous',
'Gial Ackbar', 'Goss Toowers', 'Grummgar', 'Gwellis Bagnoro',
'Han Solo',
'Jabba the Hutt', 'Jan Dodonna', 'Jango Fett', 'Jar Jar Binks',
'Kendal Ozzel',
'Lando Calrissian', 'Lobot',
'Mas Amedda', 'Maz Kanata', 'Mon Mothma',
'Nute Gunray',
'Padmé Amidala', 'Poe Dameron', 'Poggle the Lesser',
'R2-D2', 'Rune Haako',
'Sheev Palpatine', 'Shmi Skywalker', 'Sebulba', 'Sly Moore',
'Taun We',
'Watto', 'Wedge Antilles', 'Wicket Warrick', 'Wilhuff Tarkin',
'Zam Wesell',
'Ilco Munica', 'Infrablue Zedbeddy Coggins',
'Jabba the Hutt', 'Jan Dodonna', 'Jango Fett', 'Jar Jar Binks', 'Jashco Phurus', 'Jess Pava',
'Kalonia', 'Kaydel Ko Connix ', 'Kendal Ozzel', 'Korr Sella',
'Lando Calrissian', 'Lanever Villecham ', 'Larma D\'Acy', 'Lobot', 'Lor San Tekka',
'Mas Amedda', 'Maz Kanata', 'Moden Canady', 'Mon Mothma', 'Munduri',
'Nien Nunb', 'Nute Gunray',
'Padmé Amidala', 'Paige Tico', 'Phasma', 'Poe Dameron', 'Poggle the Lesser', 'Prashee', 'Praster Ommlen', 'Pru Sweevant',
'R2-D2', 'Razoo Qin-Fee', 'Rose Tico', 'Rune Haako',
'Sebulba', 'Sheev Palpatine', 'Shmi Skywalker', 'Sidon Ithano', 'Sonsigo', 'Slowen Lo', 'Sly Moore', 'Strono Tuggs',
'Sudswater Dillifay Glon',
'Tallissan Lintra', 'Taslin Brance', 'Taun We', 'Tasu Leech', 'Taybin Ralorsa', 'Temiri Blagg', 'Temmin Wexley',
'Thanisson',
'Quiggold',
'U.O. Statura', 'Ubert Quaril', 'Unamo', 'Unkar Plutt',
'Vober Dand', 'Volzang Li-Thrull',
'Watto', 'Wedge Antilles', 'Wicket Warrick', 'Wilhuff Tarkin', 'Wollivan',
'Zam Wesell', 'Zuvio',
];

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Provider/Droid.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ class Droid extends Base
*/
protected static $droids = [
'2-1B', '4-LOM', '8D8',
'BB-8',
'BB-8', 'BB-9E', 'B-U4D',
'C-3PO',
'EV-9D9',
'EGL-21', 'EV-9D9',
'FA-4',
'GA-97',
'HURID-327',
'IGG-88',
'ME-8D9',
'PZ-4CO',
'R2-D2', 'R2-Q5', 'R5-D4',
'SE8',
'TC-14',
];

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Planet.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Planet extends Base
protected static $planets = [
'Ahch-To', 'Alderaan',
'Bespin',
'Cantonica', 'Cato Neimoidia', 'Coruscant',
'Cantonica', 'Cato Neimoidia', 'Coruscant', 'Crait',
'D\'Qar', 'Dagobah',
'Endor',
'Felucia',
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Species.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Species extends Base
'Luggabeast',
'Mirialan', 'Mon Calamari',
'Nautolan', 'Neimoidian', 'Nikto',
'Pantoran', 'Pau\'an',
'Pantoran', 'Pau\'an', 'Porg',
'Quarren',
'Rodian',
'Saurin', 'Sullustan',
Expand Down
89 changes: 89 additions & 0 deletions src/Provider/Squadron.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

namespace HydrefLab\JediFaker\Provider;

use Faker\Provider\Base;

class Squadron extends Base
{
/**
* @var array
*/
protected static $pilotFormat = [
'{{squadron}} {{pilotRank}}'
];

/**
* @var string
*/
protected static $squadronWord = 'Squadron';

/**
* @var array
*/
protected static $squadron = [
'Black', 'Blade', 'Blue',
'Cobalt', 'Corona', 'Cyan',
'Danger', 'Dust',
'Exeter',
'Gray', 'Green', 'Gold',
'Havoc',
'Nomad',
'Phoenix',
'Rascal', 'Red', 'Rogue',
'Scavenger', 'Stealth',
'Wolf',
'Yellow',
];

/**
* @var array
*/
protected static $pilotRank = [
'Leader', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot',
];

/**
* @return string
*/
public function squadron(): string
{
return $this->generator->parse(static::randomElement(static::$squadron));
}

/**
* @return string
*/
public function squadronName(): string
{
return $this->generator->parse(static::randomElement(static::squadronFormat()));
}

/**
* @return string
*/
public function pilot(): string
{
$pilot = $this->generator->parse(static::randomElement(static::$pilotFormat));

return false !== strpos($pilot, 'Pilot')
? str_replace('Pilot', '#' . static::numberBetween(1, 12), $pilot)
: $pilot;
}

/**
* @return string
*/
public function pilotRank(): string
{
return $this->generator->parse(static::randomElement(static::$pilotRank));
}

/**
* @return array
*/
protected static function squadronFormat(): array
{
return ['{{squadron}} ' . static::$squadronWord];
}
}
39 changes: 39 additions & 0 deletions tests/Provider/SquadronTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace HydrefLab\JediFaker\Test;

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

class SquadronTest extends TestCase
{
public function testSquadronIsNotNull()
{
$faker = Factory::create();
$this->assertNotNull($faker->squadron);
}

public function testSquadronNameContainsSquadronWord()
{
$faker = Factory::create();
$this->assertContains('Squadron', $faker->squadronName);
}

public function testSquadronDoesNotContainSquadronWord()
{
$faker = Factory::create();
$this->assertNotContains('Squadron', $faker->squadron);
}

public function testPilotIsNotNull()
{
$faker = Factory::create();
$this->assertNotNull($faker->pilot);
}

public function testRankIsNotNull()
{
$faker = Factory::create();
$this->assertNotNull($faker->pilotRank);
}
}

0 comments on commit b3405cd

Please sign in to comment.