/**
  * Tests the name of the rule
  */
 public function testName()
 {
     $dir = new Readable();
     $this->assertEquals($dir->getName(), 'rcf_container_readable');
 }
Beispiel #2
0
    protected $error_message = 'Your container doesn\'t appear to be readable...';
    /**
     * (non-PHPdoc)
     * 
     * @see \mithra62\Validate\RuleInterface::validate()
     * @ignore
     *
     */
    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;
            }
            $client = Rcf::getRemoteClient($params, true);
            if ($client instanceof \OpenCloud\ObjectStore\Resource\Container) {
                $filesystem = new Remote(new Rcf($client, $params['rcf_container']));
                $filesystem->getAdapter()->listContents();
                return true;
            }
        } catch (\Exception $e) {
            return false;
        }
    }
}
$rule = new Readable();
\JaegerApp\Validate::addrule($rule->getName(), array($rule, 'validate'), $rule->getErrorMessage());