remove() public static method

Removes one or many directories.
public static remove ( array | string $path, array $options = [] )
$path array | string Path or paths to scan.
$options array Scanning options. Possible values are: -`'followSymlinks'` _boolean_ : Follows Symlinks if `true`. -`'recursive'` _boolean_ : Scans recursively if `true`.
コード例 #1
0
ファイル: InterceptorSpec.php プロジェクト: Ilyes512/kahlan
            Dir::remove($this->temp);
        });
        it("clears the cache", function () {
            $this->interceptor->clearCache();
            expect(file_exists($this->customCachePath))->toBe(false);
        });
        it("bails out if the cache has already been cleared", function () {
            $this->interceptor->clearCache();
            $this->interceptor->clearCache();
            expect(file_exists($this->customCachePath))->toBe(false);
        });
    });
    describe("->watch()/unwatch()", function () {
        it("add some file to be watched", function () {
            $this->temp = Dir::tempnam(null, 'cache');
            touch($this->temp . DS . 'watched1.php');
            touch($this->temp . DS . 'watched2.php');
            $watched = [$this->temp . DS . 'watched1.php', $this->temp . DS . 'watched2.php'];
            $this->interceptor = Interceptor::patch(['cachePath' => $this->cachePath]);
            $this->interceptor->watch($this->temp . DS . 'watched1.php');
            expect($this->interceptor->watched())->toBe([$watched[0]]);
            $this->interceptor->watch($this->temp . DS . 'watched2.php');
            expect($this->interceptor->watched())->toBe($watched);
            $this->interceptor->unwatch($this->temp . DS . 'watched1.php');
            expect($this->interceptor->watched())->toBe([$watched[1]]);
            $this->interceptor->unwatch($this->temp . DS . 'watched2.php');
            expect($this->interceptor->watched())->toBe([]);
            Dir::remove($this->temp);
        });
    });
});
コード例 #2
0
ファイル: Dir.spec.php プロジェクト: crysalead/kahlan
            $stat = stat($path);
            $mode = $stat['mode'] & 0777;
            expect($mode)->toBe(0755);
        });
        it("creates a nested directory with a specific mode", function () {
            $path = $this->tmpDir . '/My/Nested/Directory';
            $actual = Dir::make($path, ['mode' => 0777]);
            expect($actual)->toBe(true);
            expect(file_exists($path))->toBe(true);
            $stat = stat($path);
            $mode = $stat['mode'] & 0777;
            expect($mode)->toBe(0777);
        });
        it("creates multiple nested directories in a single call", function () {
            $paths = [$this->tmpDir . '/My/Nested/Directory', $this->tmpDir . '/Sub/Nested/Directory'];
            $actual = Dir::make($paths);
            expect($actual)->toBe(true);
            foreach ($paths as $path) {
                expect(file_exists($path))->toBe(true);
            }
        });
    });
    describe("::tempnam()", function () {
        it("uses the system temp directory by default", function () {
            $dir = Dir::tempnam(null, 'spec');
            $temp = sys_get_temp_dir();
            expect($this->normalize($dir))->toMatch('~' . $this->normalize($temp) . '/spe~');
            Dir::remove($dir);
        });
    });
});