| 27 | | $t->is(sfOutputEscaper::escape('esc_entities', null), null, '::escape() returns null if the value to escape is null'); |
|---|
| 28 | | $t->is(sfOutputEscaper::escape('esc_entities', false), false, '::escape() returns false if the value to escape is false'); |
|---|
| 29 | | $t->is(sfOutputEscaper::escape('esc_entities', true), true, '::escape() returns true if the value to escape is true'); |
|---|
| | 44 | $t->diag('::escape() does not escape special values'); |
|---|
| | 45 | $t->ok(sfOutputEscaper::escape('esc_entities', null) === null, '::escape() returns null if the value to escape is null'); |
|---|
| | 46 | $t->ok(sfOutputEscaper::escape('esc_entities', false) === false, '::escape() returns false if the value to escape is false'); |
|---|
| | 47 | $t->ok(sfOutputEscaper::escape('esc_entities', true) === true, '::escape() returns true if the value to escape is true'); |
|---|
| 36 | | $t->isa_ok(sfOutputEscaper::escape('esc_entities', array(1, 2)), 'sfOutputEscaperArrayDecorator', '::escape() returns a sfOutputEscaperArrayDecorator object if the value to escape is an array'); |
|---|
| | 56 | $t->diag('::escape() escapes arrays'); |
|---|
| | 57 | $input = array( |
|---|
| | 58 | 'foo' => '<strong>escaped!</strong>', |
|---|
| | 59 | 'bar' => array('foo' => '<strong>escaped!</strong>'), |
|---|
| | 60 | ); |
|---|
| | 61 | $output = sfOutputEscaper::escape('esc_entities', $input); |
|---|
| | 62 | $t->isa_ok($output, 'sfOutputEscaperArrayDecorator', '::escape() returns a sfOutputEscaperArrayDecorator object if the value to escape is an array'); |
|---|
| | 63 | $t->is($output['foo'], '<strong>escaped!</strong>', '::escape() escapes all elements of the original array'); |
|---|
| | 64 | $t->is($output['bar']['foo'], '<strong>escaped!</strong>', '::escape() is recursive'); |
|---|
| | 65 | $t->is($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); |
|---|
| 38 | | $t->isa_ok(sfOutputEscaper::escape('esc_entities', new stdClass()), 'sfOutputEscaperObjectDecorator', '::escape() returns a sfOutputEscaperObjectDecorator object if the value to escape is an object'); |
|---|
| | 67 | $t->diag('::escape() escapes objects'); |
|---|
| | 68 | $input = new OutputEscaperTestClass(); |
|---|
| | 69 | $output = sfOutputEscaper::escape('esc_entities', $input); |
|---|
| | 70 | $t->isa_ok($output, 'sfOutputEscaperObjectDecorator', '::escape() returns a sfOutputEscaperObjectDecorator object if the value to escape is an object'); |
|---|
| | 71 | $t->is($output->getTitle(), '<strong>escaped!</strong>', '::escape() escapes all methods of the original object'); |
|---|
| | 72 | $t->is($output->title, '<strong>escaped!</strong>', '::escape() escapes all properties of the original object'); |
|---|
| | 73 | $t->is($output->getTitleTitle(), '<strong>escaped!</strong>', '::escape() is recursive'); |
|---|
| | 74 | $t->is($output->getRawValue(), $input, '->getRawValue() returns the unescaped value'); |
|---|
| 40 | | class OutputEscaperTestClass |
|---|
| | 76 | $t->is(sfOutputEscaper::escape('esc_entities', $output)->getTitle(), '<strong>escaped!</strong>', '::escape() does not double escape an object'); |
|---|
| | 77 | $t->isa_ok(sfOutputEscaper::escape('esc_entities', new DirectoryIterator('.')), 'sfOutputEscaperIteratorDecorator', '::escape() returns a sfOutputEscaperIteratorDecorator object if the value to escape is an object that implements the ArrayAccess interface'); |
|---|
| | 78 | |
|---|
| | 79 | $t->diag('::escape() cannot escape resources'); |
|---|
| | 80 | $fh = fopen(__FILE__, 'r'); |
|---|
| | 81 | try |
|---|
| 47 | | |
|---|
| 48 | | $object = new OutputEscaperTestClass(); |
|---|
| 49 | | $escaped_object = sfOutputEscaper::escape('esc_entities', $object); |
|---|
| 50 | | $t->is(sfOutputEscaper::escape('esc_entities', $escaped_object)->getTitle(), '<strong>escaped!</strong>', '::escape() does not double escape an object'); |
|---|
| 51 | | |
|---|
| 52 | | $t->isa_ok(sfOutputEscaper::escape('esc_entities', new DirectoryIterator('.')), 'sfOutputEscaperIteratorDecorator', '::escape() returns a sfOutputEscaperIteratorDecorator object if the value to escape is an object that implements the ArrayAccess interface'); |
|---|
| | 86 | catch (InvalidArgumentException $e) |
|---|
| | 87 | { |
|---|
| | 88 | $t->pass('::escape() throws an InvalidArgumentException if the value cannot be escaped'); |
|---|
| | 89 | } |
|---|