2014-03-10 13:29:48 +07:00
|
|
|
<?php
|
2014-03-20 16:54:12 +04:00
|
|
|
namespace PhpWord\Tests\Shared;
|
2014-03-10 13:29:48 +07:00
|
|
|
|
2014-03-19 11:04:48 +04:00
|
|
|
use PhpOffice\PhpWord\Shared\File;
|
2014-03-10 13:29:48 +07:00
|
|
|
|
|
|
|
|
/**
|
2014-03-20 16:54:12 +04:00
|
|
|
* @package PhpWord\Tests
|
2014-03-19 11:04:48 +04:00
|
|
|
* @coversDefaultClass PhpOffice\PhpWord\Shared\File
|
2014-03-10 13:29:48 +07:00
|
|
|
* @runTestsInSeparateProcesses
|
|
|
|
|
*/
|
|
|
|
|
class FileTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Test file_exists()
|
|
|
|
|
*/
|
2014-03-11 21:44:54 +07:00
|
|
|
public function testFileExists()
|
2014-03-10 13:29:48 +07:00
|
|
|
{
|
2014-03-19 11:04:48 +04:00
|
|
|
$dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
|
2014-03-15 14:48:26 +07:00
|
|
|
chdir($dir);
|
2014-03-19 11:04:48 +04:00
|
|
|
$this->assertTrue(File::file_exists('blank.docx'));
|
2014-03-14 20:36:09 +01:00
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Test file_exists()
|
|
|
|
|
*/
|
|
|
|
|
public function testNoFileExists()
|
|
|
|
|
{
|
2014-03-19 11:04:48 +04:00
|
|
|
$dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
|
2014-03-15 14:48:26 +07:00
|
|
|
chdir($dir);
|
2014-03-19 11:04:48 +04:00
|
|
|
$this->assertFalse(File::file_exists('404.docx'));
|
2014-03-10 13:29:48 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test realpath()
|
|
|
|
|
*/
|
|
|
|
|
public function testRealpath()
|
|
|
|
|
{
|
2014-03-19 11:04:48 +04:00
|
|
|
$dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
|
2014-03-15 14:48:26 +07:00
|
|
|
chdir($dir);
|
|
|
|
|
$file = 'blank.docx';
|
|
|
|
|
$expected = $dir . DIRECTORY_SEPARATOR . $file;
|
2014-03-19 11:04:48 +04:00
|
|
|
$this->assertEquals($expected, File::realpath($file));
|
2014-03-10 13:29:48 +07:00
|
|
|
}
|
2014-03-19 11:04:48 +04:00
|
|
|
}
|