You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
3.8 KiB
PHP
140 lines
3.8 KiB
PHP
<?php
|
|
/**
|
|
* Zend Framework
|
|
*
|
|
* LICENSE
|
|
*
|
|
* This source file is subject to the new BSD license that is bundled
|
|
* with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://framework.zend.com/license/new-bsd
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to license@zend.com so we can send you a copy immediately.
|
|
*
|
|
* @category Zend
|
|
* @package Zend_Filter
|
|
* @subpackage UnitTests
|
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
* @version $Id: RealPathTest.php 17363 2009-08-03 07:40:18Z bkarwin $
|
|
*/
|
|
|
|
/**
|
|
* Test helper
|
|
*/
|
|
require_once dirname(__FILE__) . '/../../TestHelper.php';
|
|
|
|
/**
|
|
* @see Zend_Filter_RealPath
|
|
*/
|
|
require_once 'Zend/Filter/RealPath.php';
|
|
|
|
/**
|
|
* @category Zend
|
|
* @package Zend_Filter
|
|
* @subpackage UnitTests
|
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
* @group Zend_Filter
|
|
*/
|
|
class Zend_Filter_RealPathTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
/**
|
|
* Path to test files
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $_filesPath;
|
|
|
|
/**
|
|
* Sets the path to test files
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->_filesPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files';
|
|
}
|
|
|
|
/**
|
|
* Zend_Filter_Basename object
|
|
*
|
|
* @var Zend_Filter_Basename
|
|
*/
|
|
protected $_filter;
|
|
|
|
/**
|
|
* Creates a new Zend_Filter_Basename object for each test method
|
|
*
|
|
* @return void
|
|
*/
|
|
public function setUp()
|
|
{
|
|
$this->_filter = new Zend_Filter_RealPath();
|
|
}
|
|
|
|
/**
|
|
* Ensures expected behavior for existing file
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testFileExists()
|
|
{
|
|
$filename = 'file.1';
|
|
$this->assertContains($filename, $this->_filter->filter($this->_filesPath . DIRECTORY_SEPARATOR . $filename));
|
|
}
|
|
|
|
/**
|
|
* Ensures expected behavior for nonexistent file
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testFileNonexistent()
|
|
{
|
|
$path = '/path/to/nonexistent';
|
|
if (false !== strpos(PHP_OS, 'BSD')) {
|
|
$this->assertEquals($path, $this->_filter->filter($path));
|
|
} else {
|
|
$this->assertEquals(false, $this->_filter->filter($path));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function testGetAndSetExistsParameter()
|
|
{
|
|
$this->assertTrue($this->_filter->getExists());
|
|
$this->_filter->setExists(false);
|
|
$this->assertFalse($this->_filter->getExists());
|
|
|
|
$this->_filter->setExists(true);
|
|
$this->_filter->setExists(array('exists' => false));
|
|
$this->assertFalse($this->_filter->getExists());
|
|
|
|
$this->_filter->setExists(array('unknown'));
|
|
$this->assertTrue($this->_filter->getExists());
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function testNonExistantPath()
|
|
{
|
|
$this->_filter->setExists(false);
|
|
|
|
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files';
|
|
$this->assertEquals($path, $this->_filter->filter($path));
|
|
|
|
$path2 = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'
|
|
. DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files';
|
|
$this->assertEquals($path, $this->_filter->filter($path2));
|
|
|
|
$path3 = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'
|
|
. DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '.'
|
|
. DIRECTORY_SEPARATOR . '_files';
|
|
$this->assertEquals($path, $this->_filter->filter($path3));
|
|
}
|
|
}
|