-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DX][Internal] Do not use Alice anymore
- Loading branch information
Showing
26 changed files
with
589 additions
and
287 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
tests/Application/src/BoardGameBlog/Infrastructure/Foundry/Factory/BoardGameFactory.php
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,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\BoardGameBlog\Infrastructure\Foundry\Factory; | ||
|
||
use App\BoardGameBlog\Domain\Model\BoardGame; | ||
use App\BoardGameBlog\Domain\ValueObject\BoardGameName; | ||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; | ||
|
||
/** | ||
* @extends PersistentProxyObjectFactory<BoardGame> | ||
*/ | ||
final class BoardGameFactory extends PersistentProxyObjectFactory | ||
{ | ||
public static function class(): string | ||
{ | ||
return BoardGame::class; | ||
} | ||
|
||
public function withName(BoardGameName $name): self | ||
{ | ||
return $this->with(['name' => $name]); | ||
} | ||
|
||
protected function defaults(): array | ||
{ | ||
return [ | ||
'name' => new BoardGameName(ucfirst(self::faker()->words(2, true))), | ||
]; | ||
} | ||
|
||
protected function initialize(): static | ||
{ | ||
return parent::instantiateWith(function (array $attributes): BoardGame { | ||
return new BoardGame(...$attributes); | ||
}); | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Foundry\Factory; | ||
|
||
use App\Entity\BlogPost; | ||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; | ||
|
||
/** | ||
* @extends PersistentProxyObjectFactory<BlogPost> | ||
*/ | ||
final class BlogPostFactory extends PersistentProxyObjectFactory | ||
{ | ||
public static function class(): string | ||
{ | ||
return BlogPost::class; | ||
} | ||
|
||
public function onDraft(): self | ||
{ | ||
return $this->with(['currentPlace' => ['draft' => 1]]); | ||
} | ||
|
||
public function reviewed(): self | ||
{ | ||
return $this->with(['currentPlace' => ['reviewed' => 1]]); | ||
} | ||
|
||
protected function defaults(): array | ||
{ | ||
return []; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/Application/src/Foundry/Factory/PullRequestFactory.php
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,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Foundry\Factory; | ||
|
||
use App\Entity\PullRequest; | ||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; | ||
|
||
/** | ||
* @extends PersistentProxyObjectFactory<PullRequest> | ||
*/ | ||
final class PullRequestFactory extends PersistentProxyObjectFactory | ||
{ | ||
public static function class(): string | ||
{ | ||
return PullRequest::class; | ||
} | ||
|
||
public function withCurrentPlace(string $currentPlace): self | ||
{ | ||
return $this->with(['currentPlace' => $currentPlace]); | ||
} | ||
|
||
protected function defaults(): array | ||
{ | ||
return [ | ||
'currentPlace' => self::faker()->randomElement([ | ||
'start', | ||
'coding', | ||
'test', | ||
'review', | ||
'merged', | ||
'closed', | ||
]), | ||
]; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/Application/src/Foundry/Factory/ScienceBookFactory.php
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,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Foundry\Factory; | ||
|
||
use App\Entity\Author; | ||
use App\Entity\ScienceBook; | ||
use Doctrine\Persistence\Proxy; | ||
use function Zenstruck\Foundry\lazy; | ||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; | ||
|
||
/** | ||
* @extends PersistentProxyObjectFactory<ScienceBook> | ||
*/ | ||
final class ScienceBookFactory extends PersistentProxyObjectFactory | ||
{ | ||
public static function class(): string | ||
{ | ||
return ScienceBook::class; | ||
} | ||
|
||
public function withTitle(string $title): self | ||
{ | ||
return $this->with(['title' => $title]); | ||
} | ||
|
||
/** | ||
* @param AuthorFactory|Proxy<Author> $author | ||
*/ | ||
public function withAuthor(AuthorFactory|Proxy $author): self | ||
{ | ||
return $this->with(['author' => $author]); | ||
} | ||
|
||
protected function defaults(): array | ||
{ | ||
return [ | ||
'title' => ucfirst(self::faker()->words(2, true)), | ||
'author' => lazy(fn () => AuthorFactory::new()), | ||
]; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
tests/Application/src/Subscription/Foundry/Factory/SubscriptionFactory.php
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,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Subscription\Foundry\Factory; | ||
|
||
use App\Subscription\Entity\Subscription; | ||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; | ||
|
||
/** | ||
* @extends PersistentProxyObjectFactory<Subscription> | ||
*/ | ||
final class SubscriptionFactory extends PersistentProxyObjectFactory | ||
{ | ||
public static function class(): string | ||
{ | ||
return Subscription::class; | ||
} | ||
|
||
public function withEmail(string $email): self | ||
{ | ||
return $this->with(['email' => $email]); | ||
} | ||
|
||
public function accepted(): self | ||
{ | ||
return $this->with(['state' => 'accepted']); | ||
} | ||
|
||
protected function defaults(): array | ||
{ | ||
return [ | ||
'email' => self::faker()->email(), | ||
]; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
tests/Application/src/Subscription/Foundry/Story/DefaultSubscriptionsStory.php
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,57 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Subscription\Foundry\Story; | ||
|
||
use App\Subscription\Foundry\Factory\SubscriptionFactory; | ||
use function Zenstruck\Foundry\Persistence\flush_after; | ||
use Zenstruck\Foundry\Story; | ||
|
||
final class DefaultSubscriptionsStory extends Story | ||
{ | ||
public function build(): void | ||
{ | ||
flush_after(function () { | ||
SubscriptionFactory::new() | ||
->withEmail('marty.mcfly@bttf.com') | ||
->create() | ||
; | ||
|
||
SubscriptionFactory::new() | ||
->withEmail('doc.brown@bttf.com') | ||
->create() | ||
; | ||
|
||
SubscriptionFactory::new() | ||
->withEmail('biff.tannen@bttf.com') | ||
->accepted() | ||
->create() | ||
; | ||
|
||
SubscriptionFactory::new() | ||
->withEmail('lorraine.baines@bttf.com') | ||
->create() | ||
; | ||
|
||
SubscriptionFactory::new() | ||
->withEmail('george.mcfly@bttf.com') | ||
->create() | ||
; | ||
|
||
SubscriptionFactory::new() | ||
->withEmail('jennifer.parker@bttf.com') | ||
->create() | ||
; | ||
}); | ||
} | ||
} |
Oops, something went wrong.