function test_PingPong_pingPong() { //arrange $test_PingPong = new PingPong(); $input = 15; //act $result = $test_PingPong->runPingPong($input); //assert $this->assertEquals(array(1, 2, "ping", 4, "pong", "ping", 7, 8, "ping", "pong", 11, "ping", 13, 14, "pingpong"), $result); }
function test_PingPong_countPingPong() { //Arrange $test_PingPong = new PingPong(); $input = 15; //Act $result = $test_PingPong->makePingPong($input); //Assert $this->assertEquals(array(1, 2, 'ping', 4, 'pong', 'ping', 7, 8, 'ping', 'pong', 11, 'ping', 13, 14, 'ping-pong'), $result); }
function test_makePingPong_number() { //Arrange $test_PingPong = new PingPong(); $input = 2; //Act $result = $test_PingPong->makePingPong($input); //Assert $this->assertEquals(array(1, 2), $result); }
function testPingPong() { //Arrange $test = new PingPong(); $input = 15; //Act $result = $test->makePingPong($input); $pingPongTest = array(1, 2, "ping", 4, "pong", "ping", 7, 8, "ping", "pong", 11, "ping", 13, 14, "ping-pong"); //Assert $this->assertEquals($pingPongTest, $result); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/PingPong.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('form.html.twig'); }); $app->get("/view_ping_pong", function () use($app) { $myPingPong = new PingPong(); $pingPong = $myPingPong->makePingPong($_GET['number']); return $app['twig']->render('pingPong.html.twig', array('result' => $pingPong)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Pingpong.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('form.html.twig'); }); $app->get("/view_ping_pong", function () use($app) { $my_PingPong = new PingPong(); $new_ping_pong = $my_PingPong->makePingPong($_GET['number']); return $app['twig']->render('ping_pong.html.twig', array('result' => $new_ping_pong)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/PingPong.php"; session_start(); $app = new Silex\Application(); $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("/ping-pong", function () use($app) { $number_input = $_GET['number']; $newPingPong = new PingPong(); $results = $newPingPong->runPingPong($number_input); return $app['twig']->render('index.html.twig', array("results" => $results)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/PingPong.php"; $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); // End busy code -----------^ // Show home page $app->get("/", function () use($app) { return $app['twig']->render('pingpong.html.twig'); }); // Upon User Input - using a get, not a post $app->get("/userInput", function () use($app) { $my_input = $_GET['number']; // get user input from form $my_PingPong = new PingPong(); // create new PingPong object $results = $my_PingPong->makePingPong($my_input); // new object runs function w/user input // render html page with associative array of $results value return $app['twig']->render('pingpong.html.twig', array('results' => $results)); }); return $app; // leave this shit here!