-
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.
- Loading branch information
Yukihiro Arisawa
committed
Apr 29, 2024
1 parent
4eecb89
commit 2db8204
Showing
9 changed files
with
84 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
/.php-version | ||
/.phpcs-cache | ||
/.phpunit.cache/ | ||
.DS_Store |
Binary file not shown.
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iamyukihiro\Aquarium\UseCase; | ||
|
||
use Iamyukihiro\Aquarium\Domain\Model\Fish\Medaka; | ||
use Iamyukihiro\Aquarium\Domain\Model\Tank\TankManager; | ||
use Iamyukihiro\Aquarium\Domain\VO\Variety; | ||
|
||
class AddMedakaUseCase | ||
{ | ||
public function __construct( | ||
private TankManager $tankManager | ||
) { | ||
} | ||
|
||
public function add(): void | ||
{ | ||
$tank = $this->tankManager->load(); | ||
$tank->addFish(new Medaka('メダカ', new Variety('みゆき'), 'Swim')); | ||
$this->tankManager->save($tank); | ||
clearstatcache(); | ||
} | ||
} |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
<?php | ||
|
||
/** @noinspection NonAsciiCharacters */ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iamyukihiro\Aquarium\UseCase; | ||
|
||
use Iamyukihiro\Aquarium\Domain\Model\Tank\Tank; | ||
use Iamyukihiro\Aquarium\Domain\Model\Tank\TankManager; | ||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Argument; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use Prophecy\Prophecy\ObjectProphecy; | ||
|
||
class AddMedakaUseCaseTest extends TestCase | ||
{ | ||
use ProphecyTrait; | ||
|
||
private ObjectProphecy $tankManagerP; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->tankManagerP = $this->prophesize(TankManager::class); | ||
} | ||
|
||
public function test(): void | ||
{ | ||
$tank = new Tank(); | ||
$this->tankManagerP->load()->willReturn($tank)->shouldBeCalled(); | ||
$this->tankManagerP->save( | ||
Argument::that( | ||
function (Tank $tank) { | ||
$this->assertCount(1, $tank->getFishList()); | ||
|
||
return $tank; | ||
} | ||
) | ||
)->shouldBeCalled(); | ||
|
||
$SUT = $this->getSUT(); | ||
$SUT->add(); | ||
} | ||
|
||
public function getSUT(): AddMedakaUseCase | ||
{ | ||
return new AddMedakaUseCase( | ||
$this->tankManagerP->reveal() | ||
); | ||
} | ||
} |