ZF-8222: format class name for class checks
[zend.git] / tests / Zend / Filter / RealPathTest.php
blob732013cba4e75c5d8daa69c332e3c2ed04cef074
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
20 * @version $Id$
23 /**
24 * Test helper
26 require_once dirname(__FILE__) . '/../../TestHelper.php';
28 /**
29 * @see Zend_Filter_RealPath
31 require_once 'Zend/Filter/RealPath.php';
33 /**
34 * @category Zend
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
39 * @group Zend_Filter
41 class Zend_Filter_RealPathTest extends PHPUnit_Framework_TestCase
43 /**
44 * Path to test files
46 * @var string
48 protected $_filesPath;
50 /**
51 * Sets the path to test files
53 * @return void
55 public function __construct()
57 $this->_filesPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files';
60 /**
61 * Zend_Filter_Basename object
63 * @var Zend_Filter_Basename
65 protected $_filter;
67 /**
68 * Creates a new Zend_Filter_Basename object for each test method
70 * @return void
72 public function setUp()
74 $this->_filter = new Zend_Filter_RealPath();
77 /**
78 * Ensures expected behavior for existing file
80 * @return void
82 public function testFileExists()
84 $filename = 'file.1';
85 $this->assertContains($filename, $this->_filter->filter($this->_filesPath . DIRECTORY_SEPARATOR . $filename));
88 /**
89 * Ensures expected behavior for nonexistent file
91 * @return void
93 public function testFileNonexistent()
95 $path = '/path/to/nonexistent';
96 if (false !== strpos(PHP_OS, 'BSD')) {
97 $this->assertEquals($path, $this->_filter->filter($path));
98 } else {
99 $this->assertEquals(false, $this->_filter->filter($path));
104 * @return void
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());
121 * @return void
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));