Perforce Chronicle 2012.2/486814
API Documentation

Url_Test_UrlPathFilterTest Class Reference

Test the url path filter (normalizer). More...

List of all members.

Public Member Functions

 setUp ()
 Activate url module.
 testFilter ()
 Test various url path inputs to ensure they are normalized consistently.

Detailed Description

Test the url path filter (normalizer).

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

Url_Test_UrlPathFilterTest::setUp ( )

Activate url module.

    {
        parent::setUp();
        P4Cms_Module::fetch('Url')->enable()->load();
    }
Url_Test_UrlPathFilterTest::testFilter ( )

Test various url path inputs to ensure they are normalized consistently.

    {
        $tests = array(
            'test-path'         => 'test-path',
            'test+path'         => 'test+path',
            'special-!@$&*()'   => 'special-!@$&*()',
            'test path'         => 'test%20path',
            'bad-encode%zz'     => 'bad-encode%25zz',
            'foobar-#?'         => 'foobar-%23%3f',
            'biz/bang'          => 'biz/bang',
            'fizzle%'           => 'fizzle%25',
            '/woozle '          => 'woozle'
        );
        
        $filter = new Url_Filter_UrlPath;
        foreach ($tests as $input => $output) {
            $this->assertSame($output, $filter->filter($output));
        }
        
        // ensure filter can be run multiple times without double encoding
        $input    = "/path with spaces/";
        $expected = "path%20with%20spaces";
        $output   = $filter->filter($input);
        
        $this->assertSame($expected, $output);
        $this->assertSame($expected, $filter->filter($output));
        
        // null in, null out.
        $this->assertSame(null, $filter->filter(null));
    }

The documentation for this class was generated from the following file: