function test_makeAnagram_blah() { $test_AnagramGenerator = new AnagramGenerator(); $input = "bread"; //Act $result = $test_AnagramGenerator->makeAnagram($input); //Assert $this->assertEquals("beard", $result); }
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_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); }
// 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) { // Contact::deleteAll();
<?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;
<?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;
// 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;