tests/GameOfLife/Inputs/BoardEditor/BoardEditorTest.php
/**
     * Checks whether the board editor can launch a board editor session.
     *
     * @covers \BoardEditor\BoardEditor::launch()
     *
     * @throws \Exception
     */
Checks whether the board editor can launch a board editor session.

@throws \Exception
Checks whether the board editor can launch a board editor session . @throws \ Exception
public function testCanLaunchSession()
    {
        $this->testBoard->resetBoard();
        $this->boardEditorMock->expects($this->exactly(1))
            ->method("readInput")
            ->willReturn("exit");
        $this->boardEditorMock->expects($this->exactly(1))
            ->method("addBoardToHistory")
            ->willReturn(null);
        $optionHandlerMock = $this->getMockBuilder(BoardEditorOptionHandler::class)
                                  ->setMethods(array("parseInput"))
                                  ->disableOriginalConstructor()
                                  ->getMock();
        $shellInformationFetcherMock = $this->getMockBuilder(ShellInformationFetcher::class)
                                            ->getMock();
        if ($this->boardEditorMock instanceof BoardEditor)
        {
            if ($optionHandlerMock instanceof BoardEditorOptionHandler)
            {
                $this->boardEditorMock->setOptionHandler($optionHandlerMock);
            }
            if ($shellInformationFetcherMock instanceof ShellInformationFetcher)
            {
                $this->boardEditorMock->setShellInformationFetcher($shellInformationFetcherMock);
            }
        }
        $shellInformationFetcherMock->expects($this->exactly(1))
                                    ->method("getNumberOfShellLines")
                                    ->willReturn(10);
        $expectedOutputTitleRegex = "\n *GAME OF LIFE\n *BOARD EDITOR\n\n";
        $expectedOutputBoardRegex = " *╔═════╗\n"
                                  . " *║     ║\n"
                                  . " *║     ║\n"
                                  . " *║     ║\n"
                                  . " *║     ║\n"
                                  . " *║     ║\n"
                                  . " *╚═════╝\n*";
        $this->expectOutputRegex("/" . $expectedOutputTitleRegex . ".*" . $expectedOutputBoardRegex . "/");
        $optionHandlerMock->expects($this->exactly(1))
                          ->method("parseInput")
                          ->withConsecutive(array("exit"))
                          ->willReturn(true);
        if ($this->boardEditorMock instanceof BoardEditor) $this->boardEditorMock->launch();
    }
public function testCanLaunchSession ( ) { $ this -> testBoard -> resetBoard ( ) ; $ this -> boardEditorMock -> expects ( $ this -> exactly ( 1 ) ) -> method ( " readInput " ) -> willReturn ( " exit " ) ; $ this -> boardEditorMock -> expects ( $ this -> exactly ( 1 ) ) -> method ( " addBoardToHistory " ) -> willReturn ( null ) ; $ optionHandlerMock = $ this -> getMockBuilder ( BoardEditorOptionHandler :: class ) -> setMethods ( array ( " parseInput " ) ) -> disableOriginalConstructor ( ) -> getMock ( ) ; $ shellInformationFetcherMock = $ this -> getMockBuilder ( ShellInformationFetcher :: class ) -> getMock ( ) ; if ( $ this -> boardEditorMock instanceof BoardEditor ) { if ( $ optionHandlerMock instanceof BoardEditorOptionHandler ) { $ this -> boardEditorMock -> setOptionHandler ( $ optionHandlerMock ) ; } if ( $ shellInformationFetcherMock instanceof ShellInformationFetcher ) { $ this -> boardEditorMock -> setShellInformationFetcher ( $ shellInformationFetcherMock ) ; } } $ shellInformationFetcherMock -> expects ( $ this -> exactly ( 1 ) ) -> method ( " getNumberOfShellLines " ) -> willReturn ( 10 ) ; $ expectedOutputTitleRegex = " \n  *GAME OF LIFE \n  *BOARD EDITOR \n \n " ; $ expectedOutputBoardRegex = "  *╔═════╗\n" . "  *║     ║\n" . "  *║     ║\n" . "  *║     ║\n" . "  *║     ║\n" . "  *║     ║\n" . "  *╚═════╝\n*"; $ this -> expectOutputRegex ( " / " . $ expectedOutputTitleRegex . " .* " . $ expectedOutputBoardRegex . " / " ) ; $ optionHandlerMock -> expects ( $ this -> exactly ( 1 ) ) -> method ( " parseInput " ) -> withConsecutive ( array ( " exit " ) ) -> willReturn ( true ) ; if ( $ this -> boardEditorMock instanceof BoardEditor ) $ this -> boardEditorMock -> launch ( ) ; }
Checks whether the board editor can launch a board editor session.
Checks whether the board editor can launch a board editor session .