예제 #1
0
 function test_makeAnagram_wordWithList()
 {
     //Arrange
     $test_Anagram = new Anagram();
     $input = "on";
     $input2 = "no is";
     //Act
     $result = $test_Anagram->makeAnagram($input, $input2);
     //Assert
     $this->assertEquals("no", $result);
 }
예제 #2
0
 function test_makeAnagram_multipleWords()
 {
     //Arrange
     $test_Anagram = new Anagram();
     $input1 = "on";
     $input2 = "no an the";
     //Act
     $result = $test_Anagram->makeAnagram($input1, $input2);
     //Assert
     $this->assertEquals("no", $result);
 }
예제 #3
0
 function test_makeAnagram_arraywrong()
 {
     //Arrange
     $test_Anagram = new Anagram();
     $input = "nap";
     $comparisons = array("nap", "portland", "dog", "pan", "pen", "apn");
     //Act
     $result = $test_Anagram->makeAnagram($input, $comparisons);
     //Assert
     $this->assertEquals(array("nap", "pan", "apn"), $result);
 }
예제 #4
0
 function test_makeAnagram_otherThing()
 {
     //Arrange
     $test_Anagram = new Anagram();
     $input1 = "on";
     $input2 = "no";
     var_dump($input2);
     //Act
     $result = $test_Anagram->makeAnagram($input1, $input2);
     //Assert
     $this->assertEquals("no", $result);
 }
예제 #5
0
파일: app.php 프로젝트: sfmcewing/Anagram
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Anagram.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_anagrams", function () use($app) {
    $my_Anagram = new Anagram();
    $input_word = $my_Anagram->makeAnagram($_GET['word'], $_GET['list']);
    return $app['twig']->render('anagram.html.twig', array('result' => $input_word));
});
return $app;
예제 #6
0
파일: app.php 프로젝트: netzeln/anagram
if (empty($_SESSION['testcomparisoninput'])) {
    $_SESSION['testcomparisoninput'] = array();
}
$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->post("/enter_word", function () use($app) {
    $_SESSION['testwordinput'] = array();
    $push_word = $_POST['first_word'];
    array_push($_SESSION['testwordinput'], $push_word);
    return $app['twig']->render('index.html.twig', array('word' => $push_word));
});
$app->post("/add_compare", function () use($app) {
    $inputted_list = $_POST['comparison_words'];
    array_push($_SESSION['testcomparisoninput'], $inputted_list);
    $testarray = $_SESSION['testcomparisoninput'];
    $original_word = $_SESSION['testwordinput'][0];
    return $app['twig']->render('index.html.twig', array('tests' => $testarray, 'word' => $original_word));
});
$app->get("/clear", function () use($app) {
    $_SESSION['testcomparisoninput'] = array();
    return $app['twig']->render('index.html.twig');
});
$app->get("/show_matches", function () use($app) {
    $newAnagram = new Anagram();
    $matches = $newAnagram->makeAnagram($_SESSION['testwordinput'][0], $_SESSION['testcomparisoninput']);
    return $app['twig']->render('index.html.twig', array('matched' => $matches));
});
return $app;