Пример #1
0
 /**
  * Tests the name of the rule
  */
 public function testName()
 {
     $dir = new Writable();
     $this->assertEquals($dir->getName(), 'ftp_writable');
 }
Пример #2
0
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            $params = $params['0'];
            if (empty($params['ftp_hostname']) || empty($params['ftp_password']) || empty($params['ftp_username']) || empty($params['ftp_port']) || empty($params['ftp_store_location'])) {
                return false;
            }
            $local = new Remote(new Local(dirname($this->getTestFilePath())));
            $filesystem = new Remote(Ftp::getRemoteClient($params));
            if ($local->has($this->test_file)) {
                $contents = $local->read($this->test_file);
                $filesystem->getAdapter()->setRoot($params['ftp_store_location']);
                if ($filesystem->has($this->test_file)) {
                    $filesystem->delete($this->test_file);
                } else {
                    if ($filesystem->write($this->test_file, $contents)) {
                        $filesystem->delete($this->test_file);
                    }
                }
            }
            $filesystem->getAdapter()->disconnect();
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
}
$rule = new Writable();
\JaegerApp\Validate::addrule($rule->getName(), array($rule, 'validate'), $rule->getErrorMessage());