예제 #1
0
파일: Bootstrap.php 프로젝트: blerou/greebo
 function setup()
 {
     $container = $this->container();
     $container->vendor = 'My';
     $container->app = 'escaper';
     Escaper::register($container->event);
 }
예제 #2
0
    }
}
$escaped = Escaper::escape(new EscaperTest(), $escaper);
$t->is_deeply($escaped->foo, htmlspecialchars('<b>foo</b>'), '::escape() returns correctly escaped object property');
$t->is_deeply($escaped->bar(), htmlspecialchars('<i>bar</i>'), '::escape() returns correctly escaped object method value');
$t->diag('Array escaper');
$value = array('<i>bar</i>' => '<b>foo</b>');
$escaped = Escaper::escape($value, $escaper);
$t->is(count($escaped), count($value), '->count() works properly');
$t->is_deeply(isset($escaped['<i>bar</i>']), true, '->offsetExists() works properly');
try {
    $escaped['foo'] = 'fail';
    $t->fail('->offsetSet() throws EscaperException');
} catch (\greebo\guards\EscaperException $e) {
    $t->pass('->offsetSet() throws EscaperException');
}
try {
    unset($escaped['foo']);
    $t->fail('->offsetUnset() throws EscaperException');
} catch (\greebo\guards\EscaperException $e) {
    $t->pass('->offsetUnset() throws EscaperException');
}
$t->diag('Object escaper');
$escaped = Escaper::escape(new EscaperTest(), $escaper);
$t->is_deeply(count($escaped), 1, '->count() works properly');
try {
    $escaped->foo = 'fail';
    $t->fail('->__set() throws EscaperException');
} catch (\greebo\guards\EscaperException $e) {
    $t->pass('->__set() throws EscaperException');
}