7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Filter
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
26 require_once dirname(__FILE__
) . '/../../TestHelper.php';
29 * @see Zend_Filter_RealPath
31 require_once 'Zend/Filter/RealPath.php';
35 * @package Zend_Filter
36 * @subpackage UnitTests
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
41 class Zend_Filter_RealPathTest
extends PHPUnit_Framework_TestCase
48 protected $_filesPath;
51 * Sets the path to test files
55 public function __construct()
57 $this->_filesPath
= dirname(__FILE__
) . DIRECTORY_SEPARATOR
. '_files';
61 * Zend_Filter_Basename object
63 * @var Zend_Filter_Basename
68 * Creates a new Zend_Filter_Basename object for each test method
72 public function setUp()
74 $this->_filter
= new Zend_Filter_RealPath();
78 * Ensures expected behavior for existing file
82 public function testFileExists()
85 $this->assertContains($filename, $this->_filter
->filter($this->_filesPath
. DIRECTORY_SEPARATOR
. $filename));
89 * Ensures expected behavior for nonexistent file
93 public function testFileNonexistent()
95 $path = '/path/to/nonexistent';
96 if (false !== strpos(PHP_OS
, 'BSD')) {
97 $this->assertEquals($path, $this->_filter
->filter($path));
99 $this->assertEquals(false, $this->_filter
->filter($path));
106 public function testGetAndSetExistsParameter()
108 $this->assertTrue($this->_filter
->getExists());
109 $this->_filter
->setExists(false);
110 $this->assertFalse($this->_filter
->getExists());
112 $this->_filter
->setExists(true);
113 $this->_filter
->setExists(array('exists' => false));
114 $this->assertFalse($this->_filter
->getExists());
116 $this->_filter
->setExists(array('unknown'));
117 $this->assertTrue($this->_filter
->getExists());
123 public function testNonExistantPath()
125 $this->_filter
->setExists(false);
127 $path = dirname(__FILE__
) . DIRECTORY_SEPARATOR
. '_files';
128 $this->assertEquals($path, $this->_filter
->filter($path));
130 $path2 = dirname(__FILE__
) . DIRECTORY_SEPARATOR
. '_files'
131 . DIRECTORY_SEPARATOR
. '..' . DIRECTORY_SEPARATOR
. '_files';
132 $this->assertEquals($path, $this->_filter
->filter($path2));
134 $path3 = dirname(__FILE__
) . DIRECTORY_SEPARATOR
. '_files'
135 . DIRECTORY_SEPARATOR
. '..' . DIRECTORY_SEPARATOR
. '.'
136 . DIRECTORY_SEPARATOR
. '_files';
137 $this->assertEquals($path, $this->_filter
->filter($path3));