<?php require dirname(__FILE__) . '/../bootstrap/unit.php'; require dirname(__FILE__) . '/../../lib/validator/sfValidatorMediaBrowserDirectory.class.php'; $t = new lime_test(12, new lime_output_color()); $v = new sfValidatorMediaBrowserDirectory(); $dir = dirname(__FILE__); $t->diag('->clean()'); # valid value try { $t->is($v->clean($dir), $dir, '->clean() checks that the directory passed exists.'); } catch (sfValidatorError $e) { $t->fail('->clean() checks that the directory passed exists.'); } # cleans a misspelled directory try { $t->is($v->clean($dir . '//./'), $dir, '->clean() cleans an existing misspelled directory.'); } catch (sfValidatorError $e) { $t->fail('->clean() cleans an existing misspelled directory.'); } # invalid value try { $v->clean($dir . '/non-existing-dir'); $t->fail('->clean() throw an sfValidatorError if the value is not an existing directory'); $t->skip('', 1); } catch (sfValidatorError $e) { $t->pass('->clean() throw an sfValidatorError if the value is not an existing directory'); $t->is($e->getCode(), 'invalid', '->clean() throw an "invalid" sfValidatorError'); } # value is inside root path try {
protected function checkPath($path) { $validator = new sfValidatorMediaBrowserDirectory(array('root' => $this->root_path)); try { $validator->clean($path); return true; } catch (sfValidatorError $e) { } return false; }