| @@ 38-52 (lines=15) @@ | ||
| 35 | /** |
|
| 36 | * Tests escape() |
|
| 37 | */ |
|
| 38 | public function testEscape() { |
|
| 39 | $testSet = array( |
|
| 40 | 'foo' => 'foo', |
|
| 41 | 'foo bar' => '"foo bar"', |
|
| 42 | "foo'bar" => '"foo\'bar"', |
|
| 43 | 'foo"bar' => '"foo\"bar"', |
|
| 44 | // Newline in non-pseudo-HTML mode: escaped |
|
| 45 | "foo\nbar" => '"foo\nbar"', |
|
| 46 | ); |
|
| 47 | ||
| 48 | foreach ($testSet as $in => $expected) { |
|
| 49 | $actual = AbstractNamed::escape($in); |
|
| 50 | $this->assertEquals($expected, $actual); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | public function testEscapePseudoHtml() { |
|
| 55 | $testEscaped = array( |
|
| @@ 54-69 (lines=16) @@ | ||
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | public function testEscapePseudoHtml() { |
|
| 55 | $testEscaped = array( |
|
| 56 | // Test pseudo-HTML label: needs to be <>-wrapped. |
|
| 57 | '<b>Label</b>' => '<<b>Label</b>>', |
|
| 58 | // Test non-pseudo-HTML, non-ID label: needs to be dquote-wrapped. |
|
| 59 | 'Non HTML' => '"Non HTML"', |
|
| 60 | // Test non-pseudo-HTML, ID label: needs not be wrapped. |
|
| 61 | 'nmtoken' => 'nmtoken', |
|
| 62 | // Newline in pseudo-HTML: not converted |
|
| 63 | "<b>One\nTwo</b>" => "<<b>One\nTwo</b>>", |
|
| 64 | ); |
|
| 65 | foreach ($testEscaped as $in => $expected) { |
|
| 66 | $actual = AbstractNamed::escape($in, true); |
|
| 67 | $this->assertEquals($expected, $actual); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | } |
|
| 71 | ||
| 72 | ||