Repository: laravel/framework
File: tests/Filesystem/FilesystemTest.php (PHP)

Code before:
    public function testAllFilesFindsFiles()
    {
        file_put_contents(self::$tempDir.'/foo.txt', 'foo');
        file_put_contents(self::$tempDir.'/bar.txt', 'bar');
        $files = new Filesystem;
        $allFiles = [];
        foreach ($files->allFiles(self::$tempDir) as $file) {
            $allFiles[] = $file->getFilename();
        }
        $this->assertContains('foo.txt', $allFiles);
        $this->assertContains('bar.txt', $allFiles);
    }

    public function testDirectoriesFindsDirectories()
    {
        mkdir(self::$tempDir.'/film');
        mkdir(self::$tempDir.'/music');
        $files = new Filesystem;
        $directories = $files->directories(self::$tempDir);
        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'film', $directories);
        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'music', $directories);
    }

    public function testMakeDirectory()
    {
        $files = new Filesystem;
        $this->assertTrue($files->makeDirectory(self::$tempDir.'/created'));
        $this->assertFileExists(self::$tempDir.'/created');
    }

    #[RequiresOperatingSystem('Linux|Darwin')]
    #[RequiresPhpExtension('pcntl')]
    public function testSharedGet()
    {
        $content = str_repeat('123456', 1000000);
        $result = 1;

        posix_setpgid(0, 0);

        for ($i = 1; $i <= 20; $i++) {
            $pid = pcntl_fork();

            if (! $pid) {
                $files = new Filesystem;
                $files->put(self::$tempDir.'/file.txt', $content, true);
                $read = $files->get(self::$tempDir.'/file.txt', true);

                terminate($this, strlen($read) === strlen($content) ? 1 : 0);
            }
        }


Review comment (suggestion):
I think it's also better to use `DIRECTORY_SEPARATOR` for `mkdir`.

Code after:
    public function testAllFilesFindsFiles()
    {
        file_put_contents(self::$tempDir.'/foo.txt', 'foo');
        file_put_contents(self::$tempDir.'/bar.txt', 'bar');
        $files = new Filesystem;
        $allFiles = [];
        foreach ($files->allFiles(self::$tempDir) as $file) {
            $allFiles[] = $file->getFilename();
        }
        $this->assertContains('foo.txt', $allFiles);
        $this->assertContains('bar.txt', $allFiles);
    }

    public function testDirectoriesFindsDirectories()
    {
        mkdir(self::$tempDir.'/film');
        mkdir(self::$tempDir.'/music');
        $files = new Filesystem;
        $directories = $files->directories(self::$tempDir);
        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'film', $directories);
        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'music', $directories);
    }

    public function testAllDirectoriesFindsDirectories()
    {
        mkdir(self::$tempDir.'/film');
        mkdir(self::$tempDir.'/music');
        mkdir(self::$tempDir.'/music/rock');
        mkdir(self::$tempDir.'/music/blues');

        $directories = (new Filesystem)->allDirectories(self::$tempDir);

        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'film', $directories);
        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'music', $directories);
        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'music'.DIRECTORY_SEPARATOR.'rock', $directories);
        $this->assertContains(self::$tempDir.DIRECTORY_SEPARATOR.'music'.DIRECTORY_SEPARATOR.'blues', $directories);
    }

    public function testMakeDirectory()
    {
        $files = new Filesystem;
        $this->assertTrue($files->makeDirectory(self::$tempDir.'/created'));
        $this->assertFileExists(self::$tempDir.'/created');
    }

    #[RequiresOperatingSystem('Linux|Darwin')]
    #[RequiresPhpExtension('pcntl')]
    public function testSharedGet()
    {
        $content = str_repeat('123456', 1000000);
        $result = 1;