コード例 #1
0
 function test_checkAnagram_multipleWords()
 {
     $test_AnagramChecker = new AnagramChecker();
     $inputOne = "beard";
     $inputTwo = "bread list cat bared";
     $result = $test_AnagramChecker->checkAnagram($inputOne, $inputTwo);
     $this->assertEquals(array("bread", "bared"), $result);
 }
コード例 #2
0
 function test_checkAnagram_twoWords()
 {
     //Arrange
     $test_AnagramChecker = new AnagramChecker();
     $input = "rat";
     $comparison = "art,tar";
     //Act
     $result = $test_AnagramChecker->checkAnagram($input, $comparison);
     //Assert
     $this->assertEquals([True, True], $result);
 }
コード例 #3
0
 function test_AnagramChecker_postiveMatches()
 {
     //Arrange
     $test_AnagramChecker = new AnagramChecker();
     $input1 = "rat";
     $input2 = "I make art about tar and may name is tra";
     //Act
     $result = $test_AnagramChecker->checkAnagram($input1, $input2);
     //Assert
     $this->assertEquals(["rat", ["art", "tar", "tra"]], $result);
 }
コード例 #4
0
 function test_checkAnagram_mixedCaseGuesses()
 {
     //Arrange
     $test_AnagramChecker = new AnagramChecker();
     $input_word = "cAsh";
     $guess_array = array("doG", "cash", "moneyGunit", "yo", "saCH");
     //Act
     $result = $test_AnagramChecker->checkAnagram($input_word, $guess_array);
     //Assert
     $this->assertEquals(array("sach"), $result);
 }
コード例 #5
0
ファイル: app.php プロジェクト: ashlinaronin/anagram
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/AnagramChecker.php";
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//Routes
$app->get("/", function () use($app) {
    return $app['twig']->render('anagram_input.html.twig');
});
$app->get("/anagrams", function () use($app) {
    // If user did not input any guesses, send empty array to checker method.
    if (empty($_GET['guesses'])) {
        $guesses_array = array();
    } else {
        $guesses_array = explode(" ", $_GET['guesses']);
    }
    $new_AnagramChecker = new AnagramChecker();
    $results_array = $new_AnagramChecker->checkAnagram($_GET['input_word'], $guesses_array);
    return $app['twig']->render('anagrams.html.twig', array('results' => $results_array));
});
return $app;
コード例 #6
0
ファイル: app.php プロジェクト: umamiMike/PHP_Unit-Anagram
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/AnagramChecker.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('form.html.twig');
});
$app->get("/results", function () use($app) {
    $my_anagram = new AnagramChecker();
    $anagram_array = $my_anagram->checkAnagram($_GET['word'], $_GET['blob']);
    return $app['twig']->render('results.html.twig', array('result' => $anagram_array));
});
/*
    $app->get("/test", function() use ($app) {
        $my_anagram = new AnagramChecker();
        $my_anagram->checkAnagram("taco", "ocat");
        return $app['twig']->render('form.html.twig');
    });
*/
return $app;
コード例 #7
0
ファイル: app.php プロジェクト: jwnardini/Anagrams
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/AnagramChecker.php";
session_start();
if (empty($_SESSION['inputs'])) {
    $_SESSION['inputs'] = 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('form.html.twig');
});
// $app->post("/list", function() use ($app) {
//     $list = new AnagramChecker($_POST['anagraminput'], $_POST['anagramcandidate']);
//     $list->save();
//     return $app['twig']->render('form.html.twig', array('all_potential' => AnagramChecker::getAll()));
// });
$app->post("/anagrams", function () use($app) {
    $my_AnagramChecker = new AnagramChecker();
    $anagram = $my_AnagramChecker->checkAnagram($_POST['anagram_input'], $_POST['anagram_potential']);
    return $app['twig']->render('anagrams_checked.html.twig', array('results' => $anagram));
});
return $app;