tests/GameOfLife/GameLogicTest.php
/**
     * Checks whether the calculateNextBoard() function works as expected.
     *
     * @covers \GameOfLife\GameLogic::addToHistory()
     * @covers \GameOfLife\GameLogic::calculateNextBoard()
     */
Checks whether the calculateNextBoard() function works as expected.
Checks whether the calculateNextBoard () function works as expected .
public function testCanCalculateNextBoard()
    {
        $board = new Board(3, 3, 5, true);
        $gameLogic = new GameLogic(new ConwayRule());
        $board->setField(1, 0, true);
        $board->setField(1, 1, true);
        $board->setField(1, 2, true);
        $this->assertEquals(3, $board->getAmountCellsAlive());
        $gameLogic->calculateNextBoard($board);
        $this->assertTrue($board->getFieldStatus(0, 1));
        $this->assertTrue($board->getFieldStatus(1, 1));
        $this->assertTrue($board->getFieldStatus(2, 1));
        $this->assertEquals(3, $board->getAmountCellsAlive());
        $gameLogic->calculateNextBoard($board);
        $this->assertTrue($board->getFieldStatus(1, 0));
        $this->assertTrue($board->getFieldStatus(1, 1));
        $this->assertTrue($board->getFieldStatus(1, 2));
        $this->assertEquals(3, $board->getAmountCellsAlive());
        $this->assertEquals(2, count($gameLogic->historyOfBoards()));
    }
public function testCanCalculateNextBoard ( ) { $ board = new Board ( 3 , 3 , 5 , true ) ; $ gameLogic = new GameLogic ( new ConwayRule ( ) ) ; $ board -> setField ( 1 , 0 , true ) ; $ board -> setField ( 1 , 1 , true ) ; $ board -> setField ( 1 , 2 , true ) ; $ this -> assertEquals ( 3 , $ board -> getAmountCellsAlive ( ) ) ; $ gameLogic -> calculateNextBoard ( $ board ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 0 , 1 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 1 , 1 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 2 , 1 ) ) ; $ this -> assertEquals ( 3 , $ board -> getAmountCellsAlive ( ) ) ; $ gameLogic -> calculateNextBoard ( $ board ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 1 , 0 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 1 , 1 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 1 , 2 ) ) ; $ this -> assertEquals ( 3 , $ board -> getAmountCellsAlive ( ) ) ; $ this -> assertEquals ( 2 , count ( $ gameLogic -> historyOfBoards ( ) ) ) ; }
Checks whether the calculateNextBoard() function works as expected.
Checks whether the calculateNextBoard () function works as expected .