function test_makeAnagram_blah()
 {
     $test_AnagramGenerator = new AnagramGenerator();
     $input = "bread";
     //Act
     $result = $test_AnagramGenerator->makeAnagram($input);
     //Assert
     $this->assertEquals("beard", $result);
 }
示例#2
0
 function test_makeAnagram_verifyAnagram()
 {
     $test_AnagramGenerator = new AnagramGenerator();
     $input_word = "bread";
     $possibilities = array("beard");
     //Act
     $result = $test_AnagramGenerator->makeAnagram($input_word, $possibilities);
     //Assert
     $this->assertEquals(array('beard' => 3), $result);
 }
 function test_AnagramGenerator_Match()
 {
     //Arrange
     $test_AnagramGenerator = new AnagramGenerator();
     $input1 = "pig";
     $possibleArray = array("pig", "pug", "gip");
     //Act
     $result = $test_AnagramGenerator->matchOutput($input1, $possibleArray);
     //Assert
     $this->assertEquals(array('pig', 'gip'), $result);
 }
 function test_makeAnagram_differentLengthWords()
 {
     //Arrange
     $test_AnagramGenerator = new AnagramGenerator();
     $input = "path";
     $input2 = array("hat", "wind");
     //Act
     $result = $test_AnagramGenerator->makeAnagram($input, $input2);
     //Assert
     $this->assertEquals(array(array("hat"), array("wind")), $result);
 }
 function test_makeAnagram_partialMatch()
 {
     //Arrange
     $test_AnagramGenerator = new AnagramGenerator();
     $input_1 = "rat";
     $input_2 = "art, tart";
     //Act
     $result = $test_AnagramGenerator->makeAnagram($input_1, $input_2);
     //Assert
     $this->assertEquals(array("art", "tart"), $result);
 }
 function test_checkAnagram_complexWords()
 {
     //Arrange
     $test_AnagramGenerator = new AnagramGenerator();
     $input_single = "weasel";
     $input_list = ["selwea", "lewsae", "weasle", "chickens"];
     //Act
     $result = $test_AnagramGenerator->checkAnagram($input_single, $input_list);
     //Assert
     $this->assertEquals(["selwea", "lewsae", "weasle"], $result);
 }
 function test_makeAnagramTest_wordAsWord()
 {
     //Arrange
     $test_AnagramGenerator = new AnagramGenerator();
     $input_word = "ate";
     $guess_array = ["ate"];
     //Act
     $result = $test_AnagramGenerator->makeAnagramCase($input_word, $guess_array);
     //Assert
     $this->assertEquals(["ate"], $result);
 }
 function test_checkAnagram_twoLetterWord_noMatch()
 {
     //Arrange
     $test_AnagramGenerator = new AnagramGenerator();
     $input_single = "on";
     $input_list = "sn";
     //Act
     $result = $test_AnagramGenerator->checkAnagram($input_single, $input_list);
     //Assert
     $this->assertEquals("", $result);
 }
示例#9
0
 function test_makeAnagramMatch_singleLetter()
 {
     //Arrange
     $test_makeAnagramMatch = new AnagramGenerator();
     $input_word = "a";
     $input_list = ["a"];
     //Act
     $result = $test_makeAnagramMatch->makeAnagramMatch($input_word, $input_list);
     //Assert
     $this->assertEquals(["a"], $result);
 }
示例#10
0
// }
// For BSOD and other serious error debugging uncomment these lines:
// use Symfony\Componet\Debug\Debug;
// Debug::enable();
// Initialize application object
$app = new Silex\Application();
// Uncomment line below for debug messages
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// Use 'echo' and 'var_dump($array_name)' for variable content debugging
// Use > print_r(); to display var also
$app->get("/", function () use($app) {
    return $app['twig']->render('form.html.twig');
});
$app->get("/view_anagram_results", function () use($app) {
    $my_AnagramGenerator = new AnagramGenerator();
    $anagram_string = $my_AnagramGenerator->makeAnagram($_GET['string'], $_GET['ana1'], $_GET['ana2'], $_GET['ana3'], $_GET['ana4'], $_GET['ana5'], $_GET['ana6']);
    return $app['twig']->render('view_anagram_results.html.twig', array('result' => $anagram_string));
});
// Route for root directory to display contact entry form and all contacts
// $app->get("/", function() use ($app) {
//     return $app['twig']->render('index.html.twig', array('list_of_contacts' => Contact::getAll()));
// });
// // Route to display contact successfully created page
// $app->post("/create_contact", function() use ($app) {
//     $contact = new Contact($_POST['name'],$_POST['phone'],$_POST['address']);
//     $contact->save();
//     return $app['twig']->render('create_contact.html.twig', array('newcontact' => $contact));
// });
// // Route to display confirmation of deleting all contacts
// $app->get("/delete_contacts", function() use ($app) {
示例#11
0
文件: app.php 项目: boloround/anagram
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/AnagramGenerator.php";
// Add symfony debug component and turn it on.
use Symfony\Component\Debug\Debug;
Debug::enable();
// Initialize application
$app = new Silex\Application();
// Set Silex debug mode in $app object
$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_anagram_result", function () use($app) {
    $my_AnagramGenerator = new AnagramGenerator();
    $anagrams = $my_AnagramGenerator->makeAnagram($_GET['word'], $_GET['list']);
    return $app['twig']->render('view_anagram.html.twig', array('result' => $anagrams));
});
return $app;
示例#12
0
 function test_anagram_true_duplicateLetters()
 {
     //Arrange
     $test_anagram = new AnagramGenerator();
     $input_word = "tact";
     $input_wordsToCheck = "act cat bread bard intact interact protract bob";
     //Act
     $result = $test_anagram->anagramCheck($input_word, $input_wordsToCheck);
     //Assert
     $this->assertEquals("intact interact protract", $result);
 }
示例#13
0
文件: app.php 项目: jcubed22/Anagrams
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/AnagramGenerator.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('input_form.html.twig');
});
$app->get("/view_matches", function () use($app) {
    $my_AnagramGenerator = new AnagramGenerator();
    $matches = $my_AnagramGenerator->anagramCheck($_GET['keyword'], $_GET['wordlist']);
    $keyword = $_GET['keyword'];
    return $app['twig']->render('view_matches.html.twig', array('result' => $matches, 'keyword' => $keyword));
});
return $app;
示例#14
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/AnagramGenerator.php";
$app = new Silex\Application();
$app["debug"] = true;
//make sure this is AFTER APP STARTS
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . "/../views"));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('result' => NULL));
    //upon load the array result does not yet exist to display so we are creating a null result as a place holder.
});
$app->get("/result", function () use($app) {
    //cannot use get() on the same location/thing twice
    $my_Anagram = new AnagramGenerator();
    $possibleWords = explode(', ', $_GET['possible']);
    $initialWord = $my_Anagram->matchOutput($_GET['word'], $possibleWords);
    return $app['twig']->render('index.html.twig', array('result' => $initialWord));
});
return $app;
示例#15
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/AnagramGenerator.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_matches", function () use($app) {
    $input = $_GET['main_word'];
    $input2 = $_GET['array_of_words'];
    $input2_array = array();
    $input2_array = explode(" ", $input2);
    $anagram = new AnagramGenerator();
    $matched_words = array();
    $un_matched_words = array();
    $matched_words = $anagram->makeAnagram($input, $input2_array)[0];
    $un_matched_words = $anagram->makeAnagram($input, $input2_array)[1];
    return $app['twig']->render('view_matches.html.twig', array('matches' => $matched_words, 'nonmatches' => $un_matched_words));
});
return $app;
示例#16
0
文件: app.php 项目: r-hills/Anagram
// Dependencies
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/anagramGenerator.php";
// Initiate Session for storing data locally
// session_start();
// if (empty($_SESSION['list_of_contacts'])) {
//     $_SESSION['list_of_contacts'] = array();
// }
// For BSOD and other serious error debugging uncomment these lines:
// use Symfony\Componet\Debug\Debug;
// Debug::enable();
// Initialize application object
$app = new Silex\Application();
// Uncomment line below for debug messages
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// Use 'echo' and 'var_dump($array_name)' for variable content debugging
// Use > print_r(); to display var also
$app->get("/", function () use($app) {
    return $app['twig']->render('form.html.twig');
});
$app->get("/view_anagram_results", function () use($app) {
    $my_AnagramGenerator = new AnagramGenerator();
    $input_string = $_GET['string'];
    $possibilities = array($_GET['ana1'], $_GET['ana2'], $_GET['ana3']);
    // ,$_GET['ana4'],$_GET['ana5'],$_GET['ana6']);
    $results = $my_AnagramGenerator->makeAnagram($input_string, $possibilities);
    // $my_AnagramGenerator->setValue($results);
    return $app['twig']->render('view_anagram_results.html.twig', array('results' => $results, 'possibilities' => $possibilities, 'counter' => 0));
});
return $app;