コード例 #1
0
 public function testSetUserSetsUserId()
 {
     $user1 = $this->prophesize('AppBundle\\Entity\\User');
     $user2 = $this->prophesize('AppBundle\\Entity\\User');
     $user1->getId()->willReturn(1);
     $user2->getId()->willReturn(2);
     $this->game->setUser1($user1->reveal());
     $this->game->setUser2($user2->reveal());
     $this->assertEquals($user1->reveal(), $this->game->getUser1());
     $this->assertEquals($user2->reveal(), $this->game->getUser2());
     $this->assertEquals(1, $this->game->getUserId1());
     $this->assertEquals(2, $this->game->getUserId2());
     $this->game->setUser1($user2->reveal());
     $this->game->setUser2($user1->reveal());
     $this->assertEquals($user2->reveal(), $this->game->getUser1());
     $this->assertEquals($user1->reveal(), $this->game->getUser2());
     $this->assertEquals(2, $this->game->getUserId1());
     $this->assertEquals(1, $this->game->getUserId2());
 }
コード例 #2
0
 /**
  * @depends testAddEventShot
  * @depends testGetEventsByIdGreaterThan
  * @param Game $game
  * @param array $allEvents
  */
 public function testGetEventsByIdGreaterThanTypeShotAndPlayer(Game $game, array $allEvents)
 {
     $client = static::createClient();
     $client->enableProfiler();
     $apiKey = $this->getApiKeyManager()->generateApiKeyForUser($game->getUser1());
     $firstEvent = array_shift($allEvents);
     $playerNumber = 1;
     $client->request('GET', sprintf('/v1/games/%d/events?gt=%s&type=%s&player=%s', $game->getId(), $firstEvent['id'], Event::TYPE_SHOT, $playerNumber), [], [], ['HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => 'Bearer ' . $apiKey]);
     $response = $client->getResponse();
     $jsonResponse = json_decode($response->getContent(), true);
     $this->assertGetJsonCors($response);
     $filteredEVents = $this->filterEventsByField($allEvents, 'type', Event::TYPE_SHOT);
     $filteredEVents = $this->filterEventsByField($filteredEVents, 'player', $playerNumber);
     $this->assertEquals($filteredEVents, $jsonResponse);
 }