<?php //Loading vendor files and RPSGenerator class require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/RPSGenerator.php"; //Calling debugger use Symfony\Component\Debug\Debug; Debug::enable(); //Calling silex framework $app = new Silex\Application(); $app['debug'] = true; //calling debugger //Getting silex framework $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); //setting index page for retrieving inputs $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig'); }); //retrieving user inputs, setting instance, using makeRPS method, then posting result $app->get("/view_result", function () use($app) { $rps = new RPSGenerator(); $input2 = $_GET['player_two']; if ($input2 == 99) { $input2 = $rps->randomNumber(); } $rps_result = $rps->makeRPS($_GET['player_one'], $input2); return $app['twig']->render('result.html.twig', array('result' => $rps_result)); }); return $app;
function test_RPSGenerator_computerAsPlayerTwo() { //Arrange $test_RPSGenerator = new RPSGenerator(); $input1 = 2; //value of player 1's rock $input2 = $test_RPSGenerator->randomNumber(); //random number 3, 6, or 9 $possible_answers = array("Tie!", "Player 1 Wins!", "Player 2 Wins!"); //Act $result = $test_RPSGenerator->makeRPS($input1, $input2); //Assert $this->assertContains($result, $possible_answers); }