function test_canAttack_diagonal() { // arrange $test_Queen = new Queen(4, 4); // act $result = $test_Queen->canAttack(1, 1); $result2 = $test_Queen->canAttack(1, 3); // assert $this->assertEquals(true, $result); $this->assertEquals(false, $result2); }
function test_canAttack_horizontalAttack() { //Arrange $test_Queen = new Queen(); $input1 = 3; $input2 = 7; $input3 = 4; $input4 = 7; //Act $result = $test_Queen->canAttack($input1, $input2, $input3, $input4); //Assert $this->assertEquals(true, $result); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Queen.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('queen.html.twig'); }); $app->get('attack', function () use($app) { $my_Queen = new Queen($_GET['xq'], $_GET['yq']); $attack = $my_Queen->canAttack($_GET['xp'], $_GET['yp']); return $app['twig']->render('attack.html.twig', array('coordinates' => $attack)); //do i need to be "rendering" an array here? is that what i'm sending to twig? }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Queen.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('index.html.twig'); }); $app->get("/queen_attack", function () use($app) { $my_Queen = new Queen($_GET['qx_coord'], $_GET['qy_coord']); $results = $my_Queen->canAttack($_GET['ix_coord'], $_GET['iy_coord']); return $app['twig']->render('index.html.twig', array('result' => $results)); }); return $app;
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Queen.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_attack", function () use($app) { $my_Queen = new Queen(); $check_attack = $my_Queen->canAttack($_GET['queenx'], $_GET['queeny'], $_GET['kingx'], $_GET['kingy']); return $app['twig']->render('queen_attacked.html.twig', array('result' => $check_attack)); }); return $app;