public function testPlayerShipsAndOtherShips() { $user1 = $this->prophesize('AppBundle\\Entity\\User'); $user2 = $this->prophesize('AppBundle\\Entity\\User'); $user1Ships = ['A1']; $user2Ships = ['B2']; $user1->getId()->willReturn(1); $user2->getId()->willReturn(2); $this->game->setUser1Ships($user1Ships); $this->game->setUser2Ships($user2Ships); $this->game->setUser1($user1->reveal()); $this->game->setUser2($user2->reveal()); $this->game->setLoggedUser($user1->reveal()); $this->assertEquals($user1Ships, $this->game->getPlayerShips()); $this->assertEquals($user2Ships, $this->game->getOtherShips()); $this->game->setLoggedUser($user2->reveal()); $this->assertEquals($user2Ships, $this->game->getPlayerShips()); $this->assertEquals($user1Ships, $this->game->getOtherShips()); }
/** * @depends testAddEventShotFollowupMiss * @param Game $game */ public function testAddEventShotNotMyTurnError(Game $game) { $client = static::createClient(); $apiKey = $this->getApiKeyManager()->generateApiKeyForUser($game->getUser1()); $body = ['type' => Event::TYPE_SHOT, 'value' => $game->getOtherShips()[1]]; $client->request('POST', sprintf('/v1/games/%d/events', $game->getId()), [], [], ['CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => 'Bearer ' . $apiKey], json_encode($body)); $response = $client->getResponse(); $jsonResponse = json_decode($response->getContent(), true); $this->assertEquals(409, $response->getStatusCode(), $response); $this->assertEquals(170, $jsonResponse['code'], $response->getContent()); $this->assertEquals('It\'s other player\'s turn', $jsonResponse['message'], $response->getContent()); }