tests/GameOfLife/Inputs/BoardEditor/Options/ListOptionsOptionTest.php
/**
     * Checks whether the option can exit the board editor.
     *
     * @covers \BoardEditor\Options\ListOptionsOption::listOptions()
     */
Checks whether the option can exit the board editor.
Checks whether the option can exit the board editor .
public function testCanListOptions()
    {
        $boardEditorMock = $this->getMockBuilder(BoardEditor::class)
                                ->setMethods(array("optionHandler"))
                                ->disableOriginalConstructor()
                                ->getMock();
        $optionHandlerMock = $this->getMockBuilder(BoardEditorOptionHandler::class)
                                  ->setMethods(array("options"))
                                  ->disableOriginalConstructor()
                                  ->getMock();
        $boardEditorOptionMock = $this->getMockBuilder(BoardEditorOption::class)
                                       ->setMethods(array("arguments", "description"))
                                       ->disableOriginalConstructor()
                                       ->getMock();
        $testOption = clone $boardEditorOptionMock;
        $testOption->expects($this->exactly(1))
                   ->method("arguments")
                   ->willReturn(array());
        $testOption->expects($this->exactly(1))
                   ->method("description")
                   ->willReturn("Tests units");
        $jumpOption = clone $boardEditorOptionMock;
        $jumpOption->expects($this->exactly(1))
                   ->method("arguments")
                   ->willReturn(array("high jump" => "Bool"));
        $jumpOption->expects($this->exactly(1))
                   ->method("description")
                   ->willReturn("Makes the board jump");
        $flyOption = clone $boardEditorOptionMock;
        $flyOption->expects($this->exactly(1))
                  ->method("arguments")
                  ->willReturn(array());
        $flyOption->expects($this->exactly(1))
                  ->method("description")
                  ->willReturn("Makes the board fly");
        $boardEditorOptions = array(
            "test" => $testOption,
            "jumpVeryLongTestOption" => $jumpOption,
            "flyShort" => $flyOption
        );
        if ($boardEditorMock instanceof BoardEditor)
        {
            $listOptionsOption = new ListOptionsOption($boardEditorMock);
            $boardEditorMock->expects($this->exactly(1))
                            ->method("optionHandler")
                            ->willReturn($optionHandlerMock);
            $optionHandlerMock->expects($this->exactly(1))
                              ->method("options")
                              ->willReturn($boardEditorOptions);
            $expectedOutputRegex = "\n\nOptions:\n"
                            . " - test *: Tests units *\n"
                            . " - jumpVeryLongTestOption <high jump> *: Makes the board jump *\n"
                            . " - flyShort *: Makes the board fly *\n"
                            . "\n\n";
            $this->expectOutputRegex("/" . $expectedOutputRegex . "/");
            $result = $listOptionsOption->listOptions();
            $this->assertFalse($result);
        }
    }
public function testCanListOptions ( ) { $ boardEditorMock = $ this -> getMockBuilder ( BoardEditor :: class ) -> setMethods ( array ( " optionHandler " ) ) -> disableOriginalConstructor ( ) -> getMock ( ) ; $ optionHandlerMock = $ this -> getMockBuilder ( BoardEditorOptionHandler :: class ) -> setMethods ( array ( " options " ) ) -> disableOriginalConstructor ( ) -> getMock ( ) ; $ boardEditorOptionMock = $ this -> getMockBuilder ( BoardEditorOption :: class ) -> setMethods ( array ( " arguments " , " description " ) ) -> disableOriginalConstructor ( ) -> getMock ( ) ; $ testOption = clone $ boardEditorOptionMock ; $ testOption -> expects ( $ this -> exactly ( 1 ) ) -> method ( " arguments " ) -> willReturn ( array ( ) ) ; $ testOption -> expects ( $ this -> exactly ( 1 ) ) -> method ( " description " ) -> willReturn ( " Tests units " ) ; $ jumpOption = clone $ boardEditorOptionMock ; $ jumpOption -> expects ( $ this -> exactly ( 1 ) ) -> method ( " arguments " ) -> willReturn ( array ( " high jump " => " Bool " ) ) ; $ jumpOption -> expects ( $ this -> exactly ( 1 ) ) -> method ( " description " ) -> willReturn ( " Makes the board jump " ) ; $ flyOption = clone $ boardEditorOptionMock ; $ flyOption -> expects ( $ this -> exactly ( 1 ) ) -> method ( " arguments " ) -> willReturn ( array ( ) ) ; $ flyOption -> expects ( $ this -> exactly ( 1 ) ) -> method ( " description " ) -> willReturn ( " Makes the board fly " ) ; $ boardEditorOptions = array ( " test " => $ testOption , " jumpVeryLongTestOption " => $ jumpOption , " flyShort " => $ flyOption ) ; if ( $ boardEditorMock instanceof BoardEditor ) { $ listOptionsOption = new ListOptionsOption ( $ boardEditorMock ) ; $ boardEditorMock -> expects ( $ this -> exactly ( 1 ) ) -> method ( " optionHandler " ) -> willReturn ( $ optionHandlerMock ) ; $ optionHandlerMock -> expects ( $ this -> exactly ( 1 ) ) -> method ( " options " ) -> willReturn ( $ boardEditorOptions ) ; $ expectedOutputRegex = " \n \n Options: \n " . "  - test *: Tests units * \n " . "  - jumpVeryLongTestOption <high jump> *: Makes the board jump * \n " . "  - flyShort *: Makes the board fly * \n " . " \n \n " ; $ this -> expectOutputRegex ( " / " . $ expectedOutputRegex . " / " ) ; $ result = $ listOptionsOption -> listOptions ( ) ; $ this -> assertFalse ( $ result ) ; } }
Checks whether the option can exit the board editor.
Checks whether the option can exit the board editor .
// Generate some fake options