-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from HydrefLab/1.2
Update to v1.2
- Loading branch information
Showing
9 changed files
with
178 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |