Make WordPress Core


Ignore:
Timestamp:
03/21/2008 04:41:21 AM (18 years ago)
Author:
tellyworth
Message:

add tests for path_is_absolute

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_functions.php

    r140 r175  
    6666                $this->assertFalse(size_format(array()));
    6767        }
     68       
     69        function test_path_is_absolute() {
     70                if ( !is_callable('path_is_absolute') )
     71                        $this->markTestSkipped();
     72                       
     73                $absolute_paths = array(
     74                        '/',
     75                        '/foo/',
     76                        '/foo',
     77                        '/FOO/bar',
     78                        '/foo/bar/',
     79                        '/foo/../bar/',
     80                        '\\WINDOWS',
     81                        'C:\\',
     82                        'C:\\WINDOWS',
     83                        '\\\\sambashare\\foo',
     84                        );
     85                foreach ($absolute_paths as $path)
     86                        $this->assertTrue( path_is_absolute($path), "path_is_absolute('$path') should return true" );
     87        }
     88
     89        function test_path_is_not_absolute() {
     90                if ( !is_callable('path_is_absolute') )
     91                        $this->markTestSkipped();
     92
     93                $relative_paths = array(
     94                        '',
     95                        '.',
     96                        '..',
     97                        '../foo',
     98                        '../',
     99                        '../foo.bar',
     100                        'foo/bar',
     101                        'foo',
     102                        'FOO',
     103                        '..\\WINDOWS',
     104                        );
     105                foreach ($relative_paths as $path)
     106                        $this->assertFalse( path_is_absolute($path), "path_is_absolute('$path') should return false" );
     107        }
     108
    68109}
    69110
Note: See TracChangeset for help on using the changeset viewer.