Jyxo\Beholder\TestCase\FileSystem::run PHP Method

run() public method

Performs the test.
public run ( ) : Result
return Jyxo\Beholder\Result
    public function run() : \Jyxo\Beholder\Result
    {
        $random = md5(uniqid((string) time(), true));
        $path = $this->dir . '/beholder-' . $random . '.txt';
        $content = $random;
        // Writing
        if (!file_put_contents($path, $content)) {
            return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Write error %s', $this->dir));
        }
        // Reading
        $readContent = file_get_contents($path);
        if (strlen($readContent) !== strlen($content)) {
            return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Read error %s', $this->dir));
        }
        // Deleting
        if (!@unlink($path)) {
            return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Delete error %s', $this->dir));
        }
        // OK
        return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::SUCCESS, $this->dir);
    }