function test_countWord_wordcount3() { $test_RepeatCounter = new RepeatCounter(); $input1 = "Where is Portland? How many times have you been to Portland? What is Portland like?"; $input2 = "Portland"; $result = $test_RepeatCounter->countWord($input1, $input2); $this->assertEquals(3, $result); }
function test_countRepeats_ignorePunctuation() { $test_Repeat = new RepeatCounter(); $input1 = 'dogs'; $input2 = 'I like cats and dogs.'; $result = $test_Repeat->countRepeats($input1, $input2); $this->assertEquals(1, $result); }
function test_multipleWords() { $test_RepeatCounter = new RepeatCounter(); $input_A = "hello, goodbye"; $input_B = "hello, goodbye, hello, goodbye"; $result = $test_RepeatCounter->countRepeats($input_A, $input_B); $this->AssertEquals("error", $result); }
function test_counterRepeat_userInputsNothingSentence() { $test_RepeatCounter = new RepeatCounter(); $user_word = "taco"; $user_string = ""; $result = $test_RepeatCounter->counterRepeat($user_word, $user_string); $this->assertEquals(-1, $result); }
function test_countRepeats_matchWordIsPartOfLargerWord() { $test_RepeatCounter = new RepeatCounter(); $words_string = "This is a string, or isn't it?"; $match_word = "is"; $result = $test_RepeatCounter->countRepeats($words_string, $match_word); $this->assertEquals(1, $result[1]); }
function test_countsRepeats_emptyWord() { $test_RepeatCounter = new RepeatCounter(); $word = " "; $string_of_words = "a A"; $result = $test_RepeatCounter->countsRepeats($word, $string_of_words); $this->assertEquals("Please enter a word", $result); }
function test_countInstances_howMany() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input = "How to get to Sesame Street"; //Act $result = $test_RepeatCounter->countRepeats($input); //Assert $this->assertEquals("1", $result); }
function test_RepeatCounter_firstElementReturnsCorrectNumber() { //arrange $test_repeatCounter = new RepeatCounter(); $input1 = "string"; $input2 = "string string o the string is the string o the strings"; $result = $test_repeatCounter->countRepeats($input1, $input2); //assert $this->assertEquals(5, $result["no_of_occurences"]); }
function test_countRepeats_nonalph() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input = "They wanted to purchase each & every cookie!"; $for = "cookie"; //Act $result = $test_RepeatCounter->countRepeats($input, $for); //Assert $this->assertEquals(1, $result); }
function test_countRepeats_twins() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input = "There were seven types of cookies on the cookie platter."; $for = "cookie"; //Act $result = $test_RepeatCounter->countRepeats($input, $for); //Assert $this->assertEquals(1, $result); }
function test_count_repeats_7() { //Arrange $test_CountRepeats = new RepeatCounter(); $phrase = "Be a bee for me"; $word = "no"; //Act $result = $test_CountRepeats->countRepeats($phrase, $word); //Assert $this->assertEquals(0, $result); }
function test_RepeatCounter_noPartialMatches() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input1 = "foo"; $input2 = "foobar"; //Act $result = $test_RepeatCounter->countRepeats($input1, $input2); //Assert $this->assertEquals(0, $result); }
function test_getCounter_caseSensitive() { //Arrange $test_Counter = new RepeatCounter(); $input_word = "tHe"; $input_list = "thE monKey aNd thE frOg"; //Act $result = $test_Counter->countRepeats($input_word, $input_list); //Assert $this->assertEquals(2, $result); }
function testFive() { //Arrange $test = new RepeatCounter(); $inputWord = "hello"; $inputString = "hello john hello gabriel hello dog hello cat hello evil monster hello"; //Act $result = $test->countRepeats($inputWord, $inputString); //Assert $this->assertEquals(6, $result); }
function test_countRepeats_noMatch() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input1 = "also"; $input2 = "I do too."; //Act $results = $test_RepeatCounter->countRepeats($input1, $input2); //Assert $this->assertEquals(array("No match. Try again.", "also", "I do too."), $results); }
function test_countRepeats_compareDifferentWordsInString() { //Arrange $test_RepeatCounter = new RepeatCounter(); $word = "penguin"; $string = "I went to the zoo to see a lion."; //Act $result = $test_RepeatCounter->countRepeats($word, $string); //Assert $this->assertEquals("No words in string match original word.", $result); }
function test_countRepeats_finalTest() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input_word = "the"; $input_string = "the theater is for the thespians"; //Act $result = $test_RepeatCounter->countRepeats($input_word, $input_string); //Assert $this->assertEquals(array("the", 2), $result); }
function test_partialWord() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input_word = "Awesome"; $input_string = " Awe that is awesome"; //Act $result = $test_RepeatCounter->countRepeats($input_word, $input_string); //Assert $this->assertEquals(1, $result); }
function test_countRepeats_multipleMatch() { //Arrange $test_RepeatCounter = new RepeatCounter(); $input_one = "a"; $input_two = "A car drives down a road called a street."; //Act $result = $test_RepeatCounter->countRepeats($input_one, $input_two); //Assert $this->assertEquals("3", $result); }
function test_count_repeats_fullMatches() { //Arrange $test_countRepeats = new RepeatCounter(); $keyword = "hell"; $string = "Hello hello hello hello hello hell"; //Act $result = $test_countRepeats->countRepeats($string, $keyword); //Assert $this->assertEquals(1, $result); }
function test_countRepeats_multipleMatchingWords() { //Arrange $test = new RepeatCounter(); $input_word = "AppLe"; $input_list = "An apple fell from the tree, so I ate the apple"; //Act $result = $test->countRepeats($input_word, $input_list); //Assert $this->assertEquals(2, $result); }
function test_multiple_times() { //Arrange $test_RepeatCounter = new RepeatCounter(); $first_input = "wolf"; $second_input = "look at that wolf fighting that other wolf while the other wolf watches"; //Act $result = $test_RepeatCounter->countRepeats($first_input, $second_input); //Assert $this->assertEquals(3, $result); }
function test_countRepeats_fullWordMatch() { //Arrange $test_countRepeats = new RepeatCounter(); $word = 'Cat'; $string = 'concatinate'; //Act $result = $test_countRepeats->countRepeats($word, $string); //Assert $this->assertEquals(0, $result); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/RepeatCounter.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_matches", function () use($app) { $my_RepeatCounter = new RepeatCounter(); $my_RepeatCounter_results = $my_RepeatCounter->countRepeats($_GET['inputone'], $_GET['inputtwo']); return $app['twig']->render('view_matches.html.twig', array('result' => $my_RepeatCounter_results, 'targetword' => $_GET['inputone'], 'searchtext' => $_GET['inputtwo'])); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/RepeatCounter.php"; // Silex and Twig framworks for organization. $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); //Set path to homepage. $app->get("/", function () use($app) { return $app['twig']->render('counter_form.html.twig'); }); //Set path to results page. Push users input through countRepeats method and return results. $app->get("/results", function () use($app) { $counter = new RepeatCounter(); $counter_result = $counter->countRepeats($_GET['word'], $_GET['phrase']); return $app['twig']->render('counter_results.html.twig', array('result' => $counter_result)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/RepeatCounter.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("/results", function () use($app) { $word_result = new RepeatCounter(); $new_words = $word_result->countRepeats($_GET['first_choice'], $_GET['second_choice']); return $app['twig']->render('results.html.twig', array('result' => $new_words)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/RepeatCounter.php"; /* Pretty Standard App file for routing */ $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('home.html.twig'); }); $app->get("/result", function () use($app) { $wordCount = new RepeatCounter(); $result = $wordCount->countRepeats($_GET['word'], $_GET['wordString']); return $app['twig']->render('result.html.twig', array('result' => $result)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/RepeatCounter.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('search_form.html.twig'); }); $app->get('/search_form', function () use($app) { $my_RepeatCounter = new RepeatCounter(); $keyword = $_GET['keyword']; $string = $_GET['search_string']; $repeat_count = $my_RepeatCounter->countRepeats($_GET['search_string'], $_GET['keyword']); return $app['twig']->render('results.html.twig', array('repeats' => $repeat_count, 'keyword' => $keyword, 'string' => $string)); }); return $app;
<?php require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../src/RepeatCounter.php'; $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); //Home form page $app->get('/', function () use($app) { return $app['twig']->render('counterform.html.twig'); }); //Matched results page $app->get('/results', function () use($app) { $new_count = new RepeatCounter(); $count = $new_count->countRepeats($_GET['word'], $_GET['string']); return $app['twig']->render('counterresults.html.twig', array('results' => $count)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/RepeatCounter.php"; session_start(); $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array("twig.path" => __DIR__ . "/../views")); $app->get("/", function () use($app) { return $app["twig"]->render("wordrepeat.twig"); }); $app->get("/results", function () use($app) { $this_RepeatCounter = new RepeatCounter(); $this_game = $this_RepeatCounter->countsRepeats($_GET["word"], $_GET["string_of_words"]); return $app["twig"]->render("results.twig", array("gameinfo" => $this_game)); }); return $app;