PhpSchool\LearnYouPhp\Exercise\FilteredLs::getArgs PHP Метод

getArgs() публичный Метод

public getArgs ( ) : array
Результат array
    public function getArgs()
    {
        $folder = $this->getTemporaryPath();
        $files = ["learnyouphp.dat", "learnyouphp.txt", "learnyouphp.sql", "txt", "sql", "api.html", "html", "README.md", "CHANGELOG.md", "LICENCE.md", "md", "data.json", "json", "data.dat", "words.dat", "w00t.dat", "w00t.txt", "wrrrrongdat", "dat"];
        $this->filesystem->mkdir($folder);
        array_walk($files, function ($file) use($folder) {
            $this->filesystem->dumpFile(sprintf('%s/%s', $folder, $file), '');
        });
        $ext = '';
        while ($ext === '') {
            $index = array_rand($files);
            $ext = pathinfo($files[$index], PATHINFO_EXTENSION);
        }
        return [$folder, $ext];
    }

Usage Example

Пример #1
0
 public function testTearDownRemovesFile()
 {
     $e = new FilteredLs($this->filesystem);
     $args = $e->getArgs();
     $path = $args[0];
     $this->assertFileExists($path);
     $e->tearDown();
     $this->assertFileNotExists($path);
 }