Beispiel #1
0
 public function testCanJoin()
 {
     $user1 = $this->prophesize('AppBundle\\Entity\\User');
     $user2 = $this->prophesize('AppBundle\\Entity\\User');
     $user3 = $this->prophesize('AppBundle\\Entity\\User');
     $user1->getId()->willReturn(1);
     $user2->getId()->willReturn(2);
     $user3->getId()->willReturn(3);
     // game not available
     $this->game->setTimestamp(new \DateTime(sprintf('-%d seconds', Game::JOIN_LIMIT + 1)));
     $this->assertFalse($this->game->canJoin($user3->reveal()));
     $this->game->setUser1($user1->reveal());
     // user already owns the game
     $this->game->setTimestamp(new \DateTime());
     $this->assertFalse($this->game->canJoin($user1->reveal()));
     // user can join
     $this->game->setTimestamp(new \DateTime());
     $this->assertTrue($this->game->canJoin($user2->reveal()));
     // both users set
     $this->game->setUser2($user2->reveal());
     $this->game->setTimestamp(new \DateTime());
     $this->assertFalse($this->game->canJoin($user3->reveal()));
 }