Esempio n. 1
0
 function test_scissorsPaper()
 {
     $test_RPSTest = new RPS();
     $player1 = "scissors";
     $player2 = "paper";
     $result = $test_RPSTest->returnWinner($player1, $player2);
     $this->assertEquals("Player 1", $result);
 }
Esempio n. 2
0
 function test_RPS_Player2Wins()
 {
     $test_RPS = new RPS();
     $player1_input = 0;
     $player2_input = 1;
     //act
     $result = $test_RPS->RPS_game($player1_input, $player2_input);
     //Assert
     $this->assertEquals("Player 2 wins", $result);
 }
Esempio n. 3
0
}
if (empty($_SESSION['list_of_current_players'])) {
    $_SESSION['list_of_current_players'] = array();
}
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('form.html.twig', array('players' => Player::getAll()));
});
$app->get("/delete_all_players", function () use($app) {
    $_SESSION['list_of_current_players'] = array();
    Player::deleteAll();
    return $app['twig']->render('form.html.twig', array('players' => Player::getAll()));
});
$app->post("/create_player", function () use($app) {
    $_SESSION['list_of_current_players'] = array();
    $player = new Player($_POST['name'], $_POST['age'], $_POST['image'], $_POST['email']);
    $player->save();
    //var_dump(Player::getAll()[0]);
    return $app['twig']->render('form.html.twig', array('players' => Player::getAll()));
});
$app->get("/game", function () use($app) {
    return $app['twig']->render('game.html.twig');
});
$app->post("/results", function () use($app) {
    $rps = new RPS();
    $result = $rps->returnWinner($_POST['player1'], $_POST['player2']);
    return $app['twig']->render('results.html.twig', array('result' => $result));
});
return $app;
Esempio n. 4
0
 function test_scissors_scissors()
 {
     //Arrange
     $test_RPS = new RPS();
     $first_input = "scissors";
     $second_input = "scissors";
     //Act
     $result = $test_RPS->playGame($first_input, $second_input);
     //Assert
     $this->assertEquals("Draw", $result);
 }