function test_makePingPong_multipleNumbers()
 {
     $test_PingPongGenerator = new PingPongGenerator();
     $input = "2";
     $result = $test_PingPongGenerator->makePingPong($input);
     $this->assertEquals("1, 2", $result);
 }
예제 #2
0
 function test_makePingPong_checkThree_Five()
 {
     //Arange
     $test_PingPongGenerator = new PingPongGenerator();
     $input = 15;
     //Act
     $result = $test_PingPongGenerator->makePingPong($input);
     //Assert
     $this->assertEquals("PingPong", $result);
 }
예제 #3
0
 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);
 }
예제 #5
0
파일: app.php 프로젝트: jcfix/ping-pong-php
<?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;
예제 #6
0
<?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;