tests/GameOfLife/GameLogicTest.php
/**
     * Checks whether border passthrough and solid work as expected.
     *
     * Places a 3 x 1 Blinker next to the right border of the board and checks the game step calculation results
     *
     * @covers \GameOfLife\GameLogic::calculateNextBoard()
     *
     */
Checks whether border passthrough and solid work as expected.
Places a 3 x 1 Blinker next to the right border of the board and checks the game step calculation results


Checks whether border passthrough and solid work as expected . Places a 3 x 1 Blinker next to the right border of the board and checks the game step calculation results
public function testCanChangeBorderType()
    {
        $gameLogic = new GameLogic(new ConwayRule());
        $board = new Board(10, 10, 50, true);
        $board->setField(9, 4, true);
        $board->setField(9, 5, true);
        $board->setField(9, 6, true);
        $this->assertEquals(3, $board->getAmountCellsAlive());
        $gameLogic->calculateNextBoard($board);
        $this->assertEquals(2, $board->getAmountCellsAlive());
        $this->assertTrue($board->getFieldStatus(9, 5));
        $this->assertTrue($board->getFieldStatus(8, 5));
        $gameLogic->calculateNextBoard($board);
        $this->assertEquals(0, $board->getAmountCellsAlive());
        $board->resetBoard();
        $board->setHasBorder(false);
        $board->setField(9, 4, true);
        $board->setField(9, 5, true);
        $board->setField(9, 6, true);
        $this->assertEquals(3, $board->getAmountCellsAlive());
        $gameLogic->calculateNextBoard($board);
        $this->assertEquals(3, $board->getAmountCellsAlive());
        $this->assertTrue($board->getFieldStatus(0, 5));
        $this->assertTrue($board->getFieldStatus(9, 5));
        $this->assertTrue($board->getFieldStatus(8, 5));
        $gameLogic->calculateNextBoard($board);
        $this->assertEquals(3, $board->getAmountCellsAlive());
        $this->assertTrue($board->getFieldStatus(9, 4));
        $this->assertTrue($board->getFieldStatus(9, 5));
        $this->assertTrue($board->getFieldStatus(9, 6));
    }
public function testCanChangeBorderType ( ) { $ gameLogic = new GameLogic ( new ConwayRule ( ) ) ; $ board = new Board ( 10 , 10 , 50 , true ) ; $ board -> setField ( 9 , 4 , true ) ; $ board -> setField ( 9 , 5 , true ) ; $ board -> setField ( 9 , 6 , true ) ; $ this -> assertEquals ( 3 , $ board -> getAmountCellsAlive ( ) ) ; $ gameLogic -> calculateNextBoard ( $ board ) ; $ this -> assertEquals ( 2 , $ board -> getAmountCellsAlive ( ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 9 , 5 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 8 , 5 ) ) ; $ gameLogic -> calculateNextBoard ( $ board ) ; $ this -> assertEquals ( 0 , $ board -> getAmountCellsAlive ( ) ) ; $ board -> resetBoard ( ) ; $ board -> setHasBorder ( false ) ; $ board -> setField ( 9 , 4 , true ) ; $ board -> setField ( 9 , 5 , true ) ; $ board -> setField ( 9 , 6 , true ) ; $ this -> assertEquals ( 3 , $ board -> getAmountCellsAlive ( ) ) ; $ gameLogic -> calculateNextBoard ( $ board ) ; $ this -> assertEquals ( 3 , $ board -> getAmountCellsAlive ( ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 0 , 5 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 9 , 5 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 8 , 5 ) ) ; $ gameLogic -> calculateNextBoard ( $ board ) ; $ this -> assertEquals ( 3 , $ board -> getAmountCellsAlive ( ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 9 , 4 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 9 , 5 ) ) ; $ this -> assertTrue ( $ board -> getFieldStatus ( 9 , 6 ) ) ; }
Checks whether border passthrough and solid work as expected.
Checks whether border passthrough and solid work as expected .
// solid border // passthrough border