use Jfacchini\Battleship\BoardGame; use Jfacchini\Battleship\Exception\HitException; use Silex\Application; use Silex\Provider\SessionServiceProvider; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session; require_once __DIR__ . '/../vendor/autoload.php'; $app = new Application(); $app->register(new SessionServiceProvider()); $app->get('/', function () use($app) { /** @var Session $session */ $session = $app['session']; $game = $session->get('game'); if (is_null($game)) { $game = new BoardGame(); $game->init(); } //TODO: use twig $template = <<<TEMPLATE <!DOCTYPE html> <html> <head> <title>Battleship game</title> </head> <body> {{msg}} <pre>{{render}}</pre> <form action="/hit" method="post"> Enter coordinates (row, col), e.g. A5 <input type="text" name="coordinates" size="5" autofocus /> <input type="submit" value="Hit" />
/** * @expectedException \Jfacchini\Battleship\Exception\HitException */ public function testBadHit() { $boardGame = new BoardGame(); $boardGame->hit('J01'); }