tests/GameOfLife/Outputs/VideoOutputTest.php
/**
     * Checks whether a video can be successfully created.
     *
     * @dataProvider createVideoProvider()
     * @covers \Output\VideoOutput::outputBoard()
     * @covers \Output\VideoOutput::finishOutput()
     * @covers \Output\BaseOutput::finishOutput()
     * @covers \Output\VideoOutput::generateVideoFile()
     *
     * @param bool $_hasSound   Indicates whether the video will have sound or not
     *
     * @throws \Exception
     */
Checks whether a video can be successfully created.

@param bool $_hasSound   Indicates whether the video will have sound or not

@throws \Exception
Checks whether a video can be successfully created . @param bool $_hasSound Indicates whether the video will have sound or not @throws \ Exception
public function testCanCreateVideo(bool $_hasSound)
    {
        $ffmpegHelperMock = $this->getMockBuilder(\Output\Helpers\FfmpegHelper::class)
                                 ->disableOriginalConstructor()
                                 ->getMock();
        $ffmpegHelperMock->expects($this->exactly(1 + $_hasSound * 10))
                         ->method("executeCommand")
                         ->willReturn(false);
        if ($ffmpegHelperMock instanceof \Output\Helpers\FfmpegHelper)
        {
            $this->output->setFfmpegHelper($ffmpegHelperMock);
        }
        $this->expectOutputRegex("Starting video output ...\n\n");
        $this->output->startOutput(new Getopt(), $this->board);
        $this->output->setHasSound($_hasSound);
        for ($i = 0; $i < 10; $i++)
        {
            $this->expectOutputRegex("/.*Gamestep: " . ($i + 1) . ".*/");
            $this->output->outputBoard($this->board, false);
            $this->gameLogic->calculateNextBoard($this->board);
            $this->assertTrue(file_exists($this->outputDirectory . "tmp/Frames/" . $i . ".png"));
        }
        $outputRegex = "\nSimulation finished: All cells are dead.\n\n";
        $outputRegex .= "\nStarting video creation ...\n";
        if ($_hasSound == true)
        {
            for ($i = 0; $i < 10; $i++)
            {
                $outputRegex .= ".*\rGenerating audio ... " . ($i + 1) . "\\/10";
            }
        }
        $outputRegex .= "\nGenerating video file ...";
        $outputRegex .= "\nVideo creation complete!\n\n";
        $this->expectOutputRegex("/.*". $outputRegex . ".*/");
        $this->output->finishOutput("All cells are dead");
        $this->assertFalse(file_exists($this->outputDirectory . "tmp"));
    }
public function testCanCreateVideo ( bool $ _hasSound ) { $ ffmpegHelperMock = $ this -> getMockBuilder ( \ Output \ Helpers \ FfmpegHelper :: class ) -> disableOriginalConstructor ( ) -> getMock ( ) ; $ ffmpegHelperMock -> expects ( $ this -> exactly ( 1 + $ _hasSound * 10 ) ) -> method ( " executeCommand " ) -> willReturn ( false ) ; if ( $ ffmpegHelperMock instanceof \ Output \ Helpers \ FfmpegHelper ) { $ this -> output -> setFfmpegHelper ( $ ffmpegHelperMock ) ; } $ this -> expectOutputRegex ( " Starting video output ... \n \n " ) ; $ this -> output -> startOutput ( new Getopt ( ) , $ this -> board ) ; $ this -> output -> setHasSound ( $ _hasSound ) ; for ( $ i = 0 ; $ i < 10 ; $ i ++ ) { $ this -> expectOutputRegex ( " /.*Gamestep:  " . ( $ i + 1 ) . " .*/ " ) ; $ this -> output -> outputBoard ( $ this -> board , false ) ; $ this -> gameLogic -> calculateNextBoard ( $ this -> board ) ; $ this -> assertTrue ( file_exists ( $ this -> outputDirectory . " tmp/Frames/ " . $ i . " .png " ) ) ; } $ outputRegex = " \n Simulation finished: All cells are dead. \n \n " ; $ outputRegex .= " \n Starting video creation ... \n " ; if ( $ _hasSound == true ) { for ( $ i = 0 ; $ i < 10 ; $ i ++ ) { $ outputRegex .= " .* \r Generating audio ...  " . ( $ i + 1 ) . " \\ /10 " ; } } $ outputRegex .= " \n Generating video file ... " ; $ outputRegex .= " \n Video creation complete! \n \n " ; $ this -> expectOutputRegex ( " /.* " . $ outputRegex . " .*/ " ) ; $ this -> output -> finishOutput ( " All cells are dead " ) ; $ this -> assertFalse ( file_exists ( $ this -> outputDirectory . " tmp " ) ) ; }
Checks whether a video can be successfully created.
Checks whether a video can be successfully created .
// Create video frames and check whether the files are created // Check whether finishOutput creates the final gif //$this->assertEquals(true, file_exists($this->outputDirectory . "/Video/Game_1.mp4"));