[OutputEscaper] renamed Safe to SafeDecorator
This commit is contained in:
parent
9738f34c4d
commit
e8119ce875
|
@ -133,7 +133,7 @@ abstract class Escaper
|
|||
// return the unescaped object
|
||||
return $value;
|
||||
}
|
||||
elseif ($value instanceof Safe)
|
||||
elseif ($value instanceof SafeDecorator)
|
||||
{
|
||||
// do not escape objects marked as safe
|
||||
// return the original object
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Symfony\Components\OutputEscaper;
|
|||
* @subpackage output_escaper
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
class Safe extends \ArrayIterator
|
||||
class SafeDecorator extends \ArrayIterator
|
||||
{
|
||||
protected $value;
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
require_once __DIR__.'/../../../bootstrap.php';
|
||||
|
||||
use Symfony\Components\OutputEscaper\Escaper;
|
||||
use Symfony\Components\OutputEscaper\Safe;
|
||||
use Symfony\Components\OutputEscaper\SafeDecorator;
|
||||
use Symfony\Components\OutputEscaper\IteratorDecorator;
|
||||
use Symfony\Components\OutputEscaper\ArrayDecorator;
|
||||
use Symfony\Components\OutputEscaper\ObjectDecorator;
|
||||
|
@ -78,7 +78,7 @@ $t->is(Escaper::escape('entities', $output)->getTitle(), '<strong>escaped!
|
|||
$t->ok(Escaper::escape('entities', new \DirectoryIterator('.')) instanceof IteratorDecorator, '::escape() returns a IteratorDecorator object if the value to escape is an object that implements the ArrayAccess interface');
|
||||
|
||||
$t->diag('::escape() does not escape object marked as being safe');
|
||||
$t->ok(Escaper::escape('entities', new Safe(new OutputEscaperTestClass())) instanceof OutputEscaperTestClass, '::escape() returns the original value if it is marked as being safe');
|
||||
$t->ok(Escaper::escape('entities', new SafeDecorator(new OutputEscaperTestClass())) instanceof OutputEscaperTestClass, '::escape() returns the original value if it is marked as being safe');
|
||||
|
||||
Escaper::markClassAsSafe('OutputEscaperTestClass');
|
||||
$t->ok(Escaper::escape('entities', new OutputEscaperTestClass()) instanceof OutputEscaperTestClass, '::escape() returns the original value if the object class is marked as being safe');
|
||||
|
@ -129,7 +129,7 @@ $t->is($output->getTitleTitle(), '<strong>escaped!</strong>', '::unescape() is r
|
|||
$t->ok(IteratorDecorator::unescape(Escaper::escape('entities', new DirectoryIterator('.'))) instanceof DirectoryIterator, '::unescape() unescapes IteratorDecorator objects');
|
||||
|
||||
$t->diag('::unescape() does not unescape object marked as being safe');
|
||||
$t->ok(Escaper::unescape(Escaper::escape('entities', new Safe(new OutputEscaperTestClass()))) instanceof OutputEscaperTestClass, '::unescape() returns the original value if it is marked as being safe');
|
||||
$t->ok(Escaper::unescape(Escaper::escape('entities', new SafeDecorator(new OutputEscaperTestClass()))) instanceof OutputEscaperTestClass, '::unescape() returns the original value if it is marked as being safe');
|
||||
|
||||
Escaper::markClassAsSafe('OutputEscaperTestClass');
|
||||
$t->ok(Escaper::unescape(Escaper::escape('entities', new OutputEscaperTestClass())) instanceof OutputEscaperTestClass, '::unescape() returns the original value if the object class is marked as being safe');
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
require_once __DIR__.'/../../../bootstrap.php';
|
||||
|
||||
use Symfony\Components\OutputEscaper\Safe;
|
||||
use Symfony\Components\OutputEscaper\SafeDecorator;
|
||||
|
||||
$t = new LimeTest(13);
|
||||
|
||||
// ->getValue()
|
||||
$t->diag('->getValue()');
|
||||
$safe = new Safe('foo');
|
||||
$safe = new SafeDecorator('foo');
|
||||
$t->is($safe->getValue(), 'foo', '->getValue() returns the embedded value');
|
||||
|
||||
// ->__set() ->__get()
|
||||
|
@ -28,7 +28,7 @@ class TestClass1
|
|||
public $foo = 'bar';
|
||||
}
|
||||
|
||||
$safe = new Safe(new TestClass1());
|
||||
$safe = new SafeDecorator(new TestClass1());
|
||||
|
||||
$t->is($safe->foo, 'bar', '->__get() returns the object parameter');
|
||||
$safe->foo = 'baz';
|
||||
|
@ -45,7 +45,7 @@ class TestClass2
|
|||
}
|
||||
}
|
||||
|
||||
$safe = new Safe(new TestClass2());
|
||||
$safe = new SafeDecorator(new TestClass2());
|
||||
$t->is($safe->doSomething(), 'ok', '->__call() invokes the embedded method');
|
||||
|
||||
// ->__isset() ->__unset()
|
||||
|
@ -58,7 +58,7 @@ class TestClass3
|
|||
$nullValue = null;
|
||||
}
|
||||
|
||||
$safe = new Safe(new TestClass3());
|
||||
$safe = new SafeDecorator(new TestClass3());
|
||||
|
||||
$t->is(isset($safe->boolValue), true, '->__isset() returns true if the property is not null');
|
||||
$t->is(isset($safe->nullValue), false, '->__isset() returns false if the property is null');
|
||||
|
@ -73,7 +73,7 @@ $t->diag('Iterator');
|
|||
$input = array('one' => 1, 'two' => 2, 'three' => 3, 'children' => array(1, 2, 3));
|
||||
$output = array();
|
||||
|
||||
$safe = new Safe($input);
|
||||
$safe = new SafeDecorator($input);
|
||||
foreach ($safe as $key => $value)
|
||||
{
|
||||
$output[$key] = $value;
|
||||
|
@ -83,7 +83,7 @@ $t->same($output, $input, '"Iterator" implementation imitates an array');
|
|||
// ArrayAccess
|
||||
$t->diag('ArrayAccess');
|
||||
|
||||
$safe = new Safe(array('foo' => 'bar'));
|
||||
$safe = new SafeDecorator(array('foo' => 'bar'));
|
||||
|
||||
$t->is($safe['foo'], 'bar', '"ArrayAccess" implementation returns a value from the embedded array');
|
||||
$safe['foo'] = 'baz';
|
Reference in New Issue