public function validate($field, $input, array $params = array()) { try { if ($input == '' || empty($params['0'])) { return false; } $params = $params['0']; if (empty($params['rcf_username']) || empty($params['rcf_api']) || empty($params['rcf_container'])) { return false; } $local = new Remote(new Local(dirname($this->getTestFilePath()))); $client = Rcf::getRemoteClient($params, true); if ($client instanceof \OpenCloud\ObjectStore\Resource\Container) { $contents = $local->read($this->test_file); $filesystem = new Remote(new Rcf($client, $params['rcf_container'])); if ($filesystem->has($this->test_file)) { $filesystem->delete($this->test_file); } else { if ($filesystem->write($this->test_file, $contents)) { $filesystem->delete($this->test_file); } } return true; } } catch (\Exception $e) { return false; } } } $rule = new Writable(); \JaegerApp\Validate::addrule($rule->getName(), array($rule, 'validate'), $rule->getErrorMessage());
/** * Tests the name of the rule */ public function testName() { $dir = new Writable(); $this->assertEquals($dir->getName(), 'rcf_container_writable'); }