function test_wordScore_allLetters()
 {
     $test_ScrabbleScore = new ScrabbleScore();
     $input = "abcdefghijklmnopqrstuvwxyz";
     $result = $test_ScrabbleScore->wordScore($input);
     $this->assertEquals("87", $result);
 }
 function test_calculatorScore_multipleWords()
 {
     $test_ScrabbleScore = new ScrabbleScore();
     $userinput = "cat dog";
     $result = $test_ScrabbleScore->calculateScore($userinput);
     $this->assertEquals("Enter one word at a time.", $result);
 }
Esempio n. 3
0
 function test_ScrabbleScore_none()
 {
     $test_ScrabbleScore = new ScrabbleScore();
     $letters = null;
     //Act
     $result = $test_ScrabbleScore->makeScrabbleScore($letters);
     //Assert
     $this->assertEquals(null, $result);
 }
 function test_getScore_mixCaseWords()
 {
     //Arrange
     $test_ScrabbleScore = new ScrabbleScore();
     $input_word = "abcdEfghijklMnopQrsTuvwxyz";
     //Act
     $result = $test_ScrabbleScore->getScore($input_word);
     //Assert
     $this->assertEquals(87, $result);
 }
 function test_calculateScore_enter_not_a_word()
 {
     $test_ScrabbleScore = new ScrabbleScore();
     $input = "hjk!";
     //Act
     $result = $test_ScrabbleScore->calculateScore($input);
     //Assert
     $this->assertEquals("Not a word!", $result);
 }
Esempio n. 6
0
<?php

// Dependencies
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/ScrabbleScore.php";
// 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
// Route for root directory to display entry form
$app->get("/", function () use($app) {
    return $app['twig']->render('form.html.twig');
});
// // Route to display scrabble word and score
$app->get("/results", function () use($app) {
    $my_scrabble_score = new ScrabbleScore();
    $word = $_GET["string"];
    $results = $my_scrabble_score->calculateScore($word);
    $output_word = $results[0];
    $score = $results[1];
    return $app['twig']->render('results.html.twig', array('word' => $output_word, 'score' => $score));
});
return $app;
Esempio n. 7
0
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/ScrabbleScore.php";
// start session and check for populated word_bank array
// creates empty array if it doesn't exist
session_start();
if (empty($_SESSION['word_bank'])) {
    $_SESSION['word_bank'] = array();
}
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// displays words added to word_bank if any, displays input form
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('scrabblescores' => ScrabbleScore::getAll()));
});
$app->post("/score", function () use($app) {
    // instantiates ScrabbleScore and calculates score
    // $my_ScrabbleScore = new ScrabbleScore($_POST['userword']);
    $my_ScrabbleScore = $_POST['userword'];
    $my_ScrabbleScore_score = calculateScore($my_ScrabbleScore);
    var_dump($my_ScrabbleScore_score);
    $my_ScrabbleScore->save();
    array_push($_SESSION['word_bank'], $my_ScrabbleScore);
    // posts results to score page
    return $app['twig']->render('score.html.twig', array('result' => $my_ScrabbleScore_score, 'original' => $_POST['userword']));
});
$app->post("/delete", function () use($app) {
    ScrabbleScore::deleteAll();
    return $app['twig']->render('deleteScrabbleScore.html.twig');
});
return $app;
Esempio n. 8
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/ScrabbleScore.php";
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//Form route
$app->get("/", function () use($app) {
    return $app['twig']->render('form.html.twig');
});
//Result route
$app->get("/score", function () use($app) {
    $my_ScrabbleScore = new ScrabbleScore();
    $the_score = $my_ScrabbleScore->getScore($_GET['word']);
    return $app['twig']->render('score.html.twig', array('score' => $the_score));
});
return $app;