function test_findAnagrams_partialMatchMulti2() { $test_Anagram = new Anagram(); $input = "patht"; $words_to_check = "hat hapt hatl hatt"; $result = $test_Anagram->findAnagrams($input, $words_to_check); $this->assertEquals(["hat", "hapt", "hatt"], $result); }
function test_check_partial() { //Arrange $test_check = new Anagram('bread'); $input = 'bar'; //Act $result = $test_check->check($input); //Assert $this->assertEquals('YESSIR', $result); }
function test_findAnagram_multipleWord() { //Arrange $test_Anagram = new Anagram(); $input = "hey there"; //Act $result = $test_Anagram->findAnagram($input); //Assert $this->assertEquals("Please enter a single word.", $result); }
function test_ComparingLetters() { // Arrange $new_anagram = new Anagram(); $input = "tac"; // Act $result = $new_anagram->AnagramCheck($input); // Assert $this->assertEquals("tac act tca", $result); }
function test_findAnagram_partialWordMatch() { //Arrage $test_Anagram = new Anagram(); $word = "sa"; $test = "sag, sta, tas, abc, fun, sit"; //Act $result = $test_Anagram->findAnagram($word, $test); //Assert $this->assertEquals("sag, sta, tas", $result); }
function test_detectAnagram_capitalization() { //Arrange $test_Anagram = new Anagram(); $input_anagram = "cat"; $input_list = "CAT"; //Act $result = $test_Anagram->detectAnagram($input_anagram, $input_list); //Assert $this->assertEquals(array("CAT"), $result); }
function test_anagramFinder_onlyAnagram() { //Arrange $test_Anagram = new Anagram(); $word = "cool"; $list = "loco, milk, cool"; //Act $result = $test_Anagram->anagramFinder($word, $list); //Assert $this->assertEquals("loco", $result); }
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); }
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); }
function test_anagramCheckCompare_partial() { //Arrange $test_Anagram = new Anagram(); $input1 = "brad"; $input2 = array("beard", "bird", "apple", "bared", "debra"); //Act $result = $test_Anagram->anagramCheckCompare($input1, $input2); //Assert $this->assertEquals(array("beard", "bared", "debra"), $result); }
function test_compareWords_threeInputsMixedOutput() { //Arrange $test_Anagram = new Anagram(); $input1 = 'abc'; $input2 = 'cab,def'; //Act $result = $test_Anagram->compareWords($input1, $input2); //Assert $this->assertEquals('cab', $result); }
function test_for_sorted_list() { //Arrange $test_letter_input = new Anagram(); $word = "lemon"; $array = array("melon", "dog", "kite", "lemon"); //Act $result = $test_letter_input->checkWord($word, $array); //Assert $this->assertEquals(["melon", "lemon"], $result); }
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); }
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); }
function test_Anagram_softcompare_words() { //arrange $test_Anagram = new Anagram(); $input = "scratches"; $input2 = "sas"; $input3 = "asses"; //act $result = $test_Anagram->softCompareWords($input, $input2); $result2 = $test_Anagram->softCompareWords($input, $input3); //assert $this->assertEquals(true, $result); $this->assertEquals(false, $result2); }
function test_anagramMatch_multipleWords() { //Arrange $test_Anagram = new Anagram(); $input = "cat"; $input_list = 'cat act tac'; //Act: runs the actual method that we are testing. $result = $test_Anagram->anagramMatch($input, $input_list); $result2 = $test_Anagram->anagramMatch($input, $input_list); $result3 = $test_Anagram->anagramMatch($input, $input_list); //Assert tells our tests what to expect from the output of our method. $this->assertEquals(true, $result); $this->assertEquals(true, $result2); $this->assertEquals(true, $result3); }
function testPartialAnagram() { //Arrange $test = new Anagram(); $inputWord = "hat"; $inputList = array("scar", "ears", "dogs", "path"); //Act $result = $test->checkAnagram($inputWord, $inputList); $answer = array("path"); //Assert $this->assertEquals($answer, $result); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Anagram.php"; use Symfony\Component\Debug\Debug; Debug::enable(); $app = new Silex\Application(); $app['debug'] = true; $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("/anagram_results", function () use($app) { $new_anagram = new Anagram(); $anagram_return = $new_anagram->findAnagram($_GET['input_word']); return $app['twig']->render('anagram_results.html.twig', array('result' => $anagram_return)); }); return $app;
<?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('anagram.html.twig'); }); $app->get("/anagram", function () use($app) { $anagram = new Anagram(); $anagram_list = $anagram->findAnagram($_GET['word'], $_GET['test']); return $app['twig']->render('anagram_list.html.twig', array('result' => $anagram_list)); }); // $app->get("/anagram", function() use($app){ // $my_Anagram = new Anagram; // $my_anagram_list = $my_Anagram->findAnagram($_GET['word']); // return $app['twig']->render('anagram_list.html.twig', array('result' => $anagram_result)); // }); return $app;
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;
public function testFourLetterWord() { $anagram = new Anagram(); $result = $anagram->generate('pato'); $this->assertCount(24, $result); }
<?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('home.html.twig'); }); $app->get('/results', function () use($app) { $new_anagram = new Anagram(); $inputted_string = $_GET['user_input']; $results = $new_anagram->AnagramCheck($inputted_string); return $app['twig']->render('result.html.twig', array('anagrams' => $results)); }); return $app;
<?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('home_form.html.twig'); }); $app->get("/view_anagram", function () use($app) { $anagram_check = new Anagram(); $word = $_GET['word']; $list_to_compare = explode(" ", $_GET['list']); $list_of_anagrams = $anagram_check->checkAnagram($word, $list_to_compare); return $app['twig']->render('list_of_anagrams.html.twig', array('result' => $list_of_anagrams)); }); return $app;
<?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')); // End busy code -----------^ // Render Home Page $app->get("/", function () use($app) { return $app['twig']->render('anagram.html.twig'); // }); // Grabs User Input $app->get("/userInput", function () use($app) { $input_word = $_GET['word']; $input_list = $_GET['list']; $input_array = explode(" ", $input_list); $my_anagram = new Anagram(); $results_bool = $my_anagram->anagramMatch($input_word, $input_list); $results_match = $my_anagram->getMatchResultArray(); // calls the function to get array $results_fail = $my_anagram->getFailResultArray(); return $app['twig']->render('anagram.html.twig', array('input' => $input_word, 'list' => $input_array, 'results' => $results_bool, 'match' => $results_match, 'fail' => $results_fail)); }); return $app;
<?php //Boiler Plate require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Anagram.php"; $app = new Silex\Application(); //Twig path $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); //Link to twig files $app->get("/", function () use($app) { return $app['twig']->render('form.html.twig'); }); $app->get("/view_anagrams", function () use($app) { $my_Anagram = new Anagram(); $my_anagram_results = $my_Anagram->detectAnagram($_GET['anagram-input'], $_GET['anagram-list']); return $app['twig']->render('viewAnagrams.html.twig', array('result' => $my_anagram_results, 'original' => $_GET['anagram-input'])); }); return $app;
<?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')); // End busy code ------------^ // Render Home Page $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig'); // }); // Render Home Page $app->get("/return_results", function () use($app) { $my_anagram = new Anagram(); $result = $my_anagram->softCompareWords($_GET['master'], $_GET['test']); return $app['twig']->render('index.html.twig', array('result' => $result)); // }); return $app;
<?php require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../src/Anagram.php'; use Symfony\Component\Debug\Debug; Debug::enable(); $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('anagram.html.twig'); }); $app->get('anagramno', function () use($app) { $my_Anagram = new Anagram($_GET['a_word']); $yes_anagrams = $my_Anagram->check($_GET['the_word']); return $app['twig']->render('anagramno.html.twig', array('words' => $yes_anagrams)); var_dump($yes_anagrams); var_dump($words); }); return $app;
<?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;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Anagram.php"; use Symfony\Component\Debug\Debug; Debug::enable(); $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("/view_results", function () use($app) { $my_anagram = new Anagram(); $anagram_array = $my_anagram->findAnagrams($_GET['input_word'], $_GET["check_word"]); return $app['twig']->render('view_results.html.twig', array('result' => $anagram_array)); }); return $app;
<?php try { $arquivo = 'input.txt'; $linhas = @file($arquivo, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if ($linhas[0] == count($linhas) - 1) { unset($linhas[0]); foreach ($linhas as $linha) { $anagram = new Anagram($linha); print_r($anagram->anagramsOfpalavra()); } } else { echo "Digito validador de argumentos diferente do numero de argumentos."; } } catch (Exception $e) { echo "Não foi possivel ler o arquivo."; } function anagram_order($a, $b) { if (strtolower($a) == strtolower($b)) { return $a > $b; } return strtolower($a) > strtolower($b); } class Anagram { public $palavras = array(); public $letras = array(); public $validado = array(); public $tamanhoPalavra; public function __construct($palavra)