function test_makePingPong_multipleNumbers() { $test_PingPongGenerator = new PingPongGenerator(); $input = "2"; $result = $test_PingPongGenerator->makePingPong($input); $this->assertEquals("1, 2", $result); }
function test_makePingPong_checkThree_Five() { //Arange $test_PingPongGenerator = new PingPongGenerator(); $input = 15; //Act $result = $test_PingPongGenerator->makePingPong($input); //Assert $this->assertEquals("PingPong", $result); }
function test_replaceFifteen() { //Arrange $test_PingPongGenerator = new PingPongGenerator(); $input = 15; //Act $result = $test_PingPongGenerator->makePingPong($input); //Assert $this->assertEquals([1, 2, "ping", 4, "pong", "ping", 7, 8, "ping", "pong", 11, "ping", 13, 14, "pingpong"], $result); }
function test_forDivisibleByThreeFive() { //Arrange $test_PingPongGenerator = new PingPongGenerator(); $input = 15; //Act $result = $test_PingPongGenerator->makePingPong($input); //Assert $this->assertEquals("ping-pong", $result); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/PingPongGenerator.php"; $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('home.html.twig'); }); $app->get("/results", function () use($app) { $my_PingPongGenerator = new PingPongGenerator(); $pingPongResult = $my_PingPongGenerator->makePingPong($_GET['input_number']); return $app['twig']->render('results.html.twig', array('results' => $pingPongResult)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/PingPongGenerator.php"; $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('index.html.twig'); }); $app->get("/view_ping_pong", function () use($app) { $output_array = array(); for ($i = 1; $i <= $_GET['number']; $i++) { $number = new PingPongGenerator(); array_push($output_array, $number->makePingPong($i)); } return $app['twig']->render('ping-pong-generator.html.twig', array('result' => $output_array)); }); return $app;