<?php
/**
* Test methods for the P4Cms Editor View Helper.
*
* @copyright 2011 Perforce Software. All rights reserved.
* @license Please see LICENSE.txt in top-level folder of this distribution.
* @version <release>/<patch>
*/
class P4Cms_View_Helper_EscapeAttrTest extends TestCase
{
/**
* Test attributes escaping.
*/
public function testEscape()
{
$tests = array(
array(
'original' => "abc",
'escaped' => "abc"
),
array(
'original' => "0123456789",
'escaped' => "0123456789"
),
array(
'original' => ",.-_", //safe chars
'escaped' => ",.-_"
),
array(
'original' => "Text <tag> 123",
'escaped' => "Text <tag> 123"
),
array(
'original' => "_a,b",
'escaped' => "_a,b"
),
array(
'original' => "a-b;x",
'escaped' => "a-b;x"
),
array(
'original' => "1..n +- %x",
'escaped' => "1..n +- %x"
),
array(
'original' => "abcd<XYZ> (1,2_3)",
'escaped' => "abcd<XYZ> (1,2_3)"
),
array(
'original' => '\\n',
'escaped' => "\n"
),
array(
'original' => "\n",
'escaped' => "
"
),
array(
'original' => chr(13), // \r
'escaped' => "
"
),
array(
'original' => chr(11),
'escaped' => " "
),
array(
'original' => "\">ij",
'escaped' => "">ij"
),
array(
'original' => '_' . chr(47) . '09' . chr(58) . '-' . chr(64) . 'AZ' . chr(91)
. '-' . chr(96) . 'az' . chr(123),
'escaped' => "_/09:-@AZ[-`az{"
),
);
$view = new Zend_View;
$view->setEncoding('UTF-8');
$helper = new P4Cms_View_Helper_EscapeAttr;
$helper->setView($view);
foreach ($tests as $test) {
$this->assertSame(
$test['escaped'],
$helper->escapeAttr($test['original']),
"Unexpected escaping of '{$test['original']}'."
);
}
}
}
# |
Change |
User |
Description |
Committed |
|
#1
|
16170 |
perforce_software |
Move Chronicle files to follow new path scheme for branching. |
|
|
//guest/perforce_software/chronicle/tests/phpunit/P4Cms/View/Helper/EscapeAttrTest.php |
#1
|
8972 |
Matt Attaway |
Initial add of the Chronicle source code |
|
|