tests/GameOfLife/Utils/FileSystemHandlerTest.php
/**
     * @dataProvider writeFileProvider
     * @covers \Utils\FileSystem\FileSystemWriter::writeFile()
     * @covers \Utils\FileSystem\FileSystemReader::readFile()
     * @covers \Utils\FileSystem\FileSystemWriter::deleteFile()
     *
     * @param string $_fileName         File name of the test file
     * @param string $_content          Content of the test file
     * @param array $_expectedContent   Expected content that is read by FileSystemHandler::readFile()
     */


@param string $_fileName         File name of the test file
@param string $_content          Content of the test file
@param array $_expectedContent   Expected content that is read by FileSystemHandler::readFile()
@param string $_fileName File name of the test file @param string $_content Content of the test file @param array $_expectedContent Expected content that is read by FileSystemHandler :: readFile ()
public function testCanHandleFiles(string $_fileName, string $_content, array $_expectedContent)
    {
        $outputPath = $this->testDirectory . $this->directorySeparator . $_fileName;
        $this->assertFalse(file_exists($outputPath));
        $fileSystemReader = new FileSystemReader();
        $exceptionOccurred  = false;
        try
        {
            $this->fileSystemHandler->writeFile($this->testDirectory . "/" . $_fileName, $_content);
        }
        catch (\Exception $_exception)
        {
            $exceptionOccurred = true;
        }
        $this->assertFalse($exceptionOccurred);
        $this->assertTrue(file_exists($outputPath));
        $exceptionOccurred = false;
        try
        {
            $fileContent = $fileSystemReader->readFile($outputPath);
        }
        catch (\Exception $_exception)
        {
            $exceptionOccurred = true;
            $fileContent = array();
        }
        $this->assertFalse($exceptionOccurred);
        $this->assertEquals($_expectedContent, $fileContent);
        $exceptionOccurred = false;
        try
        {
            $this->fileSystemHandler->deleteFile($outputPath);
        }
        catch (\Exception $_exception)
        {
            $exceptionOccurred = true;
        }
        $this->assertFalse($exceptionOccurred);
        $this->assertFalse(file_exists($outputPath));
        $exceptionOccurred = false;
        try
        {
            $this->fileSystemHandler->deleteFile("nonExistingFile.notExisting");
        }
        catch (\Exception $_exception)
        {
            $exceptionOccurred = true;
            $this->assertEquals("The file \"nonExistingFile.notExisting\" does not exist.", $_exception->getMessage());
        }
        $this->assertTrue($exceptionOccurred);
    }
public function testCanHandleFiles ( string $ _fileName , string $ _content , array $ _expectedContent ) { $ outputPath = $ this -> testDirectory . $ this -> directorySeparator . $ _fileName ; $ this -> assertFalse ( file_exists ( $ outputPath ) ) ; $ fileSystemReader = new FileSystemReader ( ) ; $ exceptionOccurred = false ; try { $ this -> fileSystemHandler -> writeFile ( $ this -> testDirectory . " / " . $ _fileName , $ _content ) ; } catch ( \ Exception $ _exception ) { $ exceptionOccurred = true ; } $ this -> assertFalse ( $ exceptionOccurred ) ; $ this -> assertTrue ( file_exists ( $ outputPath ) ) ; $ exceptionOccurred = false ; try { $ fileContent = $ fileSystemReader -> readFile ( $ outputPath ) ; } catch ( \ Exception $ _exception ) { $ exceptionOccurred = true ; $ fileContent = array ( ) ; } $ this -> assertFalse ( $ exceptionOccurred ) ; $ this -> assertEquals ( $ _expectedContent , $ fileContent ) ; $ exceptionOccurred = false ; try { $ this -> fileSystemHandler -> deleteFile ( $ outputPath ) ; } catch ( \ Exception $ _exception ) { $ exceptionOccurred = true ; } $ this -> assertFalse ( $ exceptionOccurred ) ; $ this -> assertFalse ( file_exists ( $ outputPath ) ) ; $ exceptionOccurred = false ; try { $ this -> fileSystemHandler -> deleteFile ( " nonExistingFile.notExisting " ) ; } catch ( \ Exception $ _exception ) { $ exceptionOccurred = true ; $ this -> assertEquals ( " The file  \" nonExistingFile.notExisting \"  does not exist. " , $ _exception -> getMessage ( ) ) ; } $ this -> assertTrue ( $ exceptionOccurred ) ; }
@dataProvider writeFileProvider
 @covers \Utils\FileSystem\FileSystemWriter::writeFile()
 @covers \Utils\FileSystem\FileSystemReader::readFile()
 @covers \Utils\FileSystem\FileSystemWriter::deleteFile()
@dataProvider writeFileProvider @covers \ Utils \ FileSystem \ FileSystemWriter :: writeFile () @covers \ Utils \ FileSystem \ FileSystemReader :: readFile () @covers \ Utils \ FileSystem \ FileSystemWriter :: deleteFile ()