public function test_it_adds_new_deck_into_repository()
 {
     $deckId = DeckId::generate();
     $this->assertNull($this->repository->findById($deckId));
     $command = new CreateDeck($deckId);
     $this->handler->handle($command);
     $this->assertInstanceOf(Deck::class, $this->repository->findById($deckId));
 }
 public function test_it_shuffles_the_cards_within_the_deck()
 {
     $deckId = DeckId::generate();
     $deck = Deck::standard($deckId);
     $cards = $deck->getCards();
     $this->repository->add($deck);
     $this->handler->handle(new ShuffleDeck($deckId));
     $deck = $this->repository->findById($deckId);
     $this->assertNotEquals($cards, $deck->getCards());
 }
<?php

require_once __DIR__ . '/../bootstrap.php';
use DeckOfCards\Domain\Deck;
use DeckOfCards\Domain\DeckId;
use DeckOfCards\Application\Commands\ShuffleDeck;
use DeckOfCards\Application\Commands\ShuffleDeckHandler;
use DeckOfCards\Infrastructure\Repositories\InMemoryDeckRepository;
$decks = new InMemoryDeckRepository();
$deckId = DeckId::generate();
$decks->add(Deck::standard($deckId));
$locator->addHandler(new ShuffleDeckHandler($decks), ShuffleDeck::class);
$bus->handle(new ShuffleDeck((string) $deckId));
print_deck($decks->findById($deckId));
echo "\n";
<?php

require_once __DIR__ . '/../bootstrap.php';
use DeckOfCards\Domain\Deck;
use DeckOfCards\Domain\DeckId;
use DeckOfCards\Application\Commands\DrawCard;
use DeckOfCards\Application\Commands\DrawCardHandler;
use DeckOfCards\Infrastructure\Repositories\InMemoryDeckRepository;
$decks = new InMemoryDeckRepository();
$deckId = DeckId::generate();
$decks->add(Deck::standard($deckId));
$locator->addHandler(new DrawCardHandler($decks), DrawCard::class);
$card = $bus->handle(new DrawCard((string) $deckId));
print_card($card);
echo "\n";
<?php

require_once __DIR__ . '/../bootstrap.php';
use DeckOfCards\Domain\DeckId;
use DeckOfCards\Application\Commands\CreateDeck;
use DeckOfCards\Application\Commands\CreateDeckHandler;
use DeckOfCards\Infrastructure\Repositories\InMemoryDeckRepository;
$decks = new InMemoryDeckRepository();
$locator->addHandler(new CreateDeckHandler($decks), CreateDeck::class);
$deckId = DeckId::generate();
$bus->handle(new CreateDeck((string) $deckId));
print_deck($decks->findById($deckId));
echo "\n";