示例#1
0
 /**
  * @test
  */
 public function shouldRestartLastGame()
 {
     //given
     /** @var User $user1 */
     $user1 = User::create(['login' => 'A']);
     /** @var User $user2 */
     $user2 = User::create(['login' => 'B']);
     $game1 = Game::create();
     $game1->addPlayer($user1->getId());
     $game1->addPlayer($user2->getId());
     $game1->updateAttributes(['finished' => true]);
     //when
     Game::restart();
     //then
     $game = Game::findUnfinishedGame();
     $this->assertFalse($game->isFinished());
     $this->assertTrue($game->isStarted());
     Assert::thatArray(GameUser::where(['game_id' => $game->getId()])->fetchAll())->hasSize(2)->onProperty('user_id')->containsExactly($user1->getId(), $user2->getId());
 }
示例#2
0
 public function cancel()
 {
     Game::findUnfinishedGame()->delete();
     $this->redirect(indexHomePath());
 }