/** * @test */ public function testPlayerCreated() { $gameId = $this->getMiniGameId(666); $playerId = $this->getPlayerId(42); $lives = 6; $event = new HangmanPlayerCreatedEvent($gameId, $playerId, 'name', $lives, 'ext'); $this->assertEquals($gameId, $event->getGameId()); $this->assertEquals($playerId, $event->getPlayerId()); $this->assertEquals('name', $event->getPlayerName()); $this->assertEquals($lives, $event->getLives()); $this->assertEquals('ext', $event->getExternalReference()); }
/** * Apply the player created event * * @param HangmanPlayerCreatedEvent $event * @return void */ protected function applyHangmanPlayerCreatedEvent(HangmanPlayerCreatedEvent $event) { $player = new HangmanPlayer($event->getPlayerId(), $event->getPlayerName(), $event->getLives(), $this, $event->getExternalReference()); $this->gameOrder[] = (string) $player->getId(); $this->players[(string) $player->getId()] = $player; }