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_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_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_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_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_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_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 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_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 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_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_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_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); }
<?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;
function test_punctuationString() { $test_repeatCounter = new RepeatCounter(); $input_word = "Hello"; $input_string = "Hello, my name has always been Ben"; $result = $test_repeatCounter->countRepeats($input_word, $input_string); $this->assertEquals(1, $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')); //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'; // class(s) goes here //required for silex $app = new Silex\Application(); // allows twig to be used in the views folders $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); // points to home page after tests pass $app->get("/", function () use($app) { return $app['twig']->render('form.html.twig'); }); // this is where the function goes for app->get! $app->get("/count_repeats", function () use($app) { //link to class name $my_RepeatCounter = new RepeatCounter(); //needed to get variables $your_repeats = $my_RepeatCounter->countRepeats($_GET['word'], $_GET['string']); //return the output with twig as stated above return $app['twig']->render('view.html.twig', array('result' => $your_repeats)); }); // always needed to actually return the app 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')); $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"; /* 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('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"; $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'); }); // check file names methods etc $app->get("/view_instances", function () use($app) { $my_RepeatCounter = new RepeatCounter(); $instances_counted = $my_RepeatCounter->countRepeats($_GET['string']); return $app['twig']->render('instances_counted.html.twig', array('result' => $instances_counted)); }); 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')); $app->get("/", function () use($app) { return $app['twig']->render('home.html.twig'); }); $app->get("/matches", function () use($app) { $results = new RepeatCounter(); $total_matches = $results->countRepeats($_GET['word'], $_GET['sentence']); return $app['twig']->render('matches.html.twig', array('matches' => $total_matches)); }); 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"; 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')); //now for our pages $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig'); }); $app->get("/view_result", function () use($app) { $word = new RepeatCounter(); $value = $word->countRepeats($_GET['sentence'], $_GET['word']); //I want different output on result page if it returns a count or if it returns an error. $value_number = 0; $value_string = ""; if (is_string($value)) { $value_string = $value; } else { $value_number = $value; } //now we will pass both of those variables into the results page return $app['twig']->render('result.html.twig', array('value_string' => $value_string, 'value_number' => $value_number)); }); return $app;