Exemple #1
0
 public function testStart()
 {
     $board = \Mockery::mock('TickTackToe\\Board')->shouldReceive('findWinner')->atLeast(2)->shouldReceive('hasMovesLeft')->atLeast(2)->shouldReceive('getFields')->atLeast(2)->andReturn([0, 0, 0, 0, 0, 0, 0, 0, 0])->getMock();
     $player1 = \Mockery::mock('TickTackToe\\Player')->shouldReceive('makeMove')->atLeast(1)->getMock();
     $player2 = \Mockery::mock('TickTackToe\\Player')->shouldReceive('makeMove')->atLeast(1)->getMock();
     $game = new Game($board, $player1, $player2);
     $game->start();
 }
Exemple #2
0
<?php

/**
 * Start the Game
 */
use TickTackToe\Game;
use TickTackToe\Board;
use TickTackToe\Player;
use TickTackToe\Strategy\RandomStrategy;
require "vendor/autoload.php";
$board = new Board();
$player1 = new Player('Bob', new RandomStrategy());
$player2 = new Player('Joe', new RandomStrategy());
$game = new Game($board, $player1, $player2);
$winner = $game->start();
dump($winner);
dump($game->getNumberOfMoves());