This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #41 from localheinz/feature/faker-aware-definition
Enhancement: Allow to provide definitions with an instance of Faker\Generator
- Loading branch information
Showing
8 changed files
with
226 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017 Andreas Möller. | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @link https://github.com/localheinz/factory-girl-definition | ||
*/ | ||
|
||
namespace Localheinz\FactoryGirl\Definition; | ||
|
||
use Faker\Generator; | ||
|
||
interface FakerAwareDefinition extends Definition | ||
{ | ||
public function provideWith(Generator $faker); | ||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017 Andreas Möller. | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @link https://github.com/localheinz/factory-girl-definition | ||
*/ | ||
|
||
namespace Localheinz\FactoryGirl\Definition\Test\Fixture\Definition\FakerAware; | ||
|
||
use FactoryGirl\Provider\Doctrine\FixtureFactory; | ||
use Faker\Generator; | ||
use Localheinz\FactoryGirl\Definition\FakerAwareDefinition; | ||
use Localheinz\FactoryGirl\Definition\Test\Fixture\Entity; | ||
|
||
final class GroupDefinition implements FakerAwareDefinition | ||
{ | ||
/** | ||
* @var Generator | ||
*/ | ||
private $faker; | ||
|
||
public function accept(FixtureFactory $factory) | ||
{ | ||
$factory->defineEntity(Entity\Group::class); | ||
} | ||
|
||
public function provideWith(Generator $faker) | ||
{ | ||
$this->faker = $faker; | ||
} | ||
|
||
public function faker() | ||
{ | ||
return $this->faker; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017 Andreas Möller. | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @link https://github.com/localheinz/factory-girl-definition | ||
*/ | ||
|
||
namespace Localheinz\FactoryGirl\Definition\Test\Fixture\Definition\FakerAware; | ||
|
||
use FactoryGirl\Provider\Doctrine\FixtureFactory; | ||
use Localheinz\FactoryGirl\Definition\Definition; | ||
use Localheinz\FactoryGirl\Definition\Test\Fixture\Entity; | ||
|
||
final class UserDefinition implements Definition | ||
{ | ||
public function accept(FixtureFactory $factory) | ||
{ | ||
$factory->defineEntity(Entity\Group::class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017 Andreas Möller. | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @link https://github.com/localheinz/factory-girl-definition | ||
*/ | ||
|
||
namespace Localheinz\FactoryGirl\Definition\Test\Fixture\Entity; | ||
|
||
final class Group | ||
{ | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2017 Andreas Möller. | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @link https://github.com/localheinz/factory-girl-definition | ||
*/ | ||
|
||
namespace Localheinz\FactoryGirl\Definition\Test\Unit; | ||
|
||
use Localheinz\FactoryGirl\Definition\Definition; | ||
use Localheinz\FactoryGirl\Definition\FakerAwareDefinition; | ||
use Localheinz\Test\Util\Helper; | ||
use PHPUnit\Framework; | ||
|
||
final class FakerAwareDefinitionTest extends Framework\TestCase | ||
{ | ||
use Helper; | ||
|
||
public function testExtendsDefinitionInterface() | ||
{ | ||
$this->assertInterfaceExtends(Definition::class, FakerAwareDefinition::class); | ||
} | ||
} |