Passage en Namespace et tous les tests fonctionnels OK
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
<?php
|
||||
/** DomFramework
|
||||
@package domframework
|
||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
/** Test the domframework file part */
|
||||
class fileTest extends \PHPUnit_Framework_TestCase
|
||||
namespace Domframework\Tests;
|
||||
|
||||
use Domframework\File;
|
||||
|
||||
/** Test the domframework File part */
|
||||
class FileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testinit ()
|
||||
{
|
||||
@@ -13,56 +19,56 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRealPath01 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->realpath ("/tmp");
|
||||
$this->assertSame($res, "/tmp");
|
||||
}
|
||||
|
||||
public function testRealPath02 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->realpath ("////tmp");
|
||||
$this->assertSame($res, "/tmp");
|
||||
}
|
||||
|
||||
public function testRealPath03 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->realpath ("////tmp////");
|
||||
$this->assertSame($res, "/tmp");
|
||||
}
|
||||
|
||||
public function testRealPath04 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->realpath (".////tmp////");
|
||||
$this->assertSame($res, "./tmp");
|
||||
}
|
||||
|
||||
public function testRealPath05 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->realpath ("../../../../../tmp/file");
|
||||
$this->assertSame($res, "/tmp/file");
|
||||
}
|
||||
|
||||
public function testRealPath06 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->realpath ("../../../../../tmp/file/../../../..");
|
||||
$this->assertSame($res, "/");
|
||||
}
|
||||
|
||||
public function testRealPath07 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->realpath (".././././../tmp/file/../././..");
|
||||
$this->assertSame($res, "/");
|
||||
}
|
||||
|
||||
public function testRealPath11 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->realpath ("/tmp2");
|
||||
$this->assertSame($res, "/tmp/tmp2");
|
||||
@@ -70,7 +76,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRealPath12 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->realpath ("////tmp2");
|
||||
$this->assertSame($res, "/tmp/tmp2");
|
||||
@@ -78,7 +84,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRealPath13 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->realpath ("////tmp2////");
|
||||
$this->assertSame($res, "/tmp/tmp2");
|
||||
@@ -86,7 +92,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRealPath14 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->realpath (".////tmp2////");
|
||||
$this->assertSame($res, "/tmp/tmp2");
|
||||
@@ -94,7 +100,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRealPath15 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->realpath ("../../../../../tmp2/file");
|
||||
$this->assertSame($res, "/tmp/tmp2/file");
|
||||
@@ -102,7 +108,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRealPath16 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->realpath ("../../../../../tmp2/file/../../../..");
|
||||
$this->assertSame($res, "/tmp");
|
||||
@@ -110,7 +116,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRealPath17 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->realpath (".././././../tmp2/file/../././..");
|
||||
$this->assertSame($res, "/tmp");
|
||||
@@ -119,14 +125,14 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetcwd1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->getcwd ();
|
||||
$this->assertSame($res, ".");
|
||||
}
|
||||
|
||||
public function testGetcwd2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("/tmp");
|
||||
$res = $file->getcwd ();
|
||||
$this->assertSame($res, "/tmp");
|
||||
@@ -135,13 +141,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetcwd3 ()
|
||||
{
|
||||
$this->setExpectedException ("Exception", "Path '/NON EXISTS' not found");
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("/NON EXISTS");
|
||||
$res = $file->getcwd ();
|
||||
}
|
||||
public function testGetcwd4 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("/../../../tmp");
|
||||
$res = $file->getcwd ();
|
||||
$this->assertSame($res, "/tmp");
|
||||
@@ -149,7 +155,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetcwd5 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("../../../../../../tmp");
|
||||
$res = $file->getcwd ();
|
||||
$this->assertSame($res, "/tmp");
|
||||
@@ -158,7 +164,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetcwd6 ()
|
||||
{
|
||||
$this->setExpectedException ("Exception", "Path './tmp' not found");
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("./tmp");
|
||||
$res = $file->getcwd ();
|
||||
}
|
||||
@@ -167,7 +173,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException ("Exception",
|
||||
"Path '/tmp/NON EXISTS' not found");
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("/tmp/NON EXISTS");
|
||||
$res = $file->getcwd ();
|
||||
}
|
||||
@@ -176,7 +182,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException ("Exception",
|
||||
"Parent Path '/NON EXISTS/' not found");
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("/NON EXISTS/tmp");
|
||||
$res = $file->getcwd ();
|
||||
}
|
||||
@@ -184,13 +190,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
public function testchroot1 ()
|
||||
{
|
||||
$this->setExpectedException ("Exception");
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->chroot ("non exists");
|
||||
}
|
||||
|
||||
public function testchroot2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->chroot ("/tmp");
|
||||
$this->assertSame($res, true);
|
||||
}
|
||||
@@ -198,7 +204,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
// Without chroot
|
||||
public function testMkdir1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->mkdir ("/tmp/testmkdir1-".time());
|
||||
$this->assertSame($res, true);
|
||||
}
|
||||
@@ -206,7 +212,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
// With chroot in tmp
|
||||
public function testMkdir2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->chroot ("/tmp");
|
||||
$res = $file->mkdir ("/testmkdir2-".time());
|
||||
$this->assertSame($res, true);
|
||||
@@ -215,7 +221,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
// Without chroot and relative
|
||||
public function testMkdir3 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->mkdir ("/tmp/testmkdir3-".time());
|
||||
$this->assertSame($res, true);
|
||||
}
|
||||
@@ -223,7 +229,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
// With chroot in tmp and in relative
|
||||
public function testMkdir4 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->chroot ("/tmp");
|
||||
$res = $file->mkdir ("testmkdir4-".time());
|
||||
$this->assertSame($res, true);
|
||||
@@ -232,8 +238,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
// With chroot in tmp
|
||||
public function testChdir1 ()
|
||||
{
|
||||
@rmdir ("/tmp/testDFFileDir");
|
||||
$file = new file ();
|
||||
if (file_exists ("/tmp/testDFFileDir"))
|
||||
rmdir ("/tmp/testDFFileDir");
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->mkdir ("/testDFFileDir");
|
||||
$file->chdir ("/testDFFileDir");
|
||||
@@ -244,8 +251,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
// With chroot in tmp
|
||||
public function testChdir2 ()
|
||||
{
|
||||
@rmdir ("/tmp/testDFFileDir");
|
||||
$file = new file ();
|
||||
if (file_exists ("/tmp/testDFFileDir"))
|
||||
rmdir ("/tmp/testDFFileDir");
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->mkdir ("/testDFFileDir");
|
||||
$file->chroot ("/");
|
||||
@@ -259,8 +267,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException ("Exception",
|
||||
"Path '/tmp/testDFFileDir/NON EXISTS' not found");
|
||||
@rmdir ("/tmp/testDFFileDir");
|
||||
$file = new file ();
|
||||
if (file_exists ("/tmp/testDFFileDir"))
|
||||
rmdir ("/tmp/testDFFileDir");
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->mkdir ("/testDFFileDir");
|
||||
$file->chroot ("/testDFFileDir");
|
||||
@@ -272,8 +281,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException ("Exception",
|
||||
"Parent Path '/tmp/tmp/' not found");
|
||||
@rmdir ("/tmp/testDFFileDir");
|
||||
$file = new file ();
|
||||
if (file_exists ("/tmp/testDFFileDir"))
|
||||
rmdir ("/tmp/testDFFileDir");
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->mkdir ("/testDFFileDir");
|
||||
$file->chroot ("..");
|
||||
@@ -284,8 +294,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException ("Exception",
|
||||
"File '/tmp/testDFFileDir' is not a file");
|
||||
@rmdir ("/tmp/testDFFileDir");
|
||||
$file = new file ();
|
||||
if (file_exists ("/tmp/testDFFileDir"))
|
||||
rmdir ("/tmp/testDFFileDir");
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->mkdir ("/testDFFileDir");
|
||||
$res = $file->file_get_contents ("/testDFFileDir");
|
||||
@@ -293,8 +304,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testFile_get_contents2 ()
|
||||
{
|
||||
@rmdir ("/tmp/testDFFileDir");
|
||||
$file = new file ();
|
||||
if (file_exists ("/tmp/testDFFileDir"))
|
||||
rmdir ("/tmp/testDFFileDir");
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->mkdir ("/testDFFileDir");
|
||||
$file->touch ("/testDFFileDir/toto");
|
||||
@@ -304,7 +316,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testFile_put_contents1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->file_put_contents ("/testDFFileDir/toto", "content");
|
||||
$res = $file->file_get_contents ("/testDFFileDir/toto");
|
||||
@@ -315,13 +327,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException ("Exception",
|
||||
"File '/tmp/testDFFileDir' is not a file");
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->file_put_contents ("/tmp/testDFFileDir", "content");
|
||||
}
|
||||
|
||||
public function testFile_put_contents3 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->file_put_contents ("/testDFFileDir/toto", "content");
|
||||
$this->assertSame($res, 7);
|
||||
@@ -329,14 +341,14 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testscandir1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->scandir ("/tmp/testDFFileDir");
|
||||
$this->assertSame ($res, array ("toto"));
|
||||
}
|
||||
|
||||
public function testscandir2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->scandir ("/testDFFileDir");
|
||||
$this->assertSame ($res, array ("toto"));
|
||||
@@ -344,7 +356,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testscandir3 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->scandir ("/testDFFileDir/");
|
||||
$this->assertSame ($res, array ("toto"));
|
||||
@@ -353,7 +365,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
public function testrmdir1 ()
|
||||
{
|
||||
// Directory not empty and NOT recursive : return false
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->rmdir ("/tmp/testDFFileDir");
|
||||
$this->assertSame ($res, false);
|
||||
}
|
||||
@@ -361,7 +373,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
public function testrmdir2 ()
|
||||
{
|
||||
// Directory not empty and NOT recursive : return false
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->rmdir ("/testDFFileDir");
|
||||
$this->assertSame ($res, false);
|
||||
@@ -370,7 +382,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
public function testrmdir3 ()
|
||||
{
|
||||
// Directory not empty and recursive : return true
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->rmdir ("/testDFFileDir", true);
|
||||
$this->assertSame ($res, true);
|
||||
@@ -378,8 +390,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUnlink1 ()
|
||||
{
|
||||
@rmdir ("/tmp/testDFFileDir");
|
||||
$file = new file ();
|
||||
if (file_exists ("/tmp/testDFFileDir"))
|
||||
rmdir ("/tmp/testDFFileDir");
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->mkdir ("/testDFFileDir");
|
||||
$file->touch ("/testDFFileDir/toto");
|
||||
@@ -389,7 +402,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testIsDir1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->is_dir ("//testDFFileDir");
|
||||
$this->assertSame ($res, true);
|
||||
@@ -397,7 +410,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testIsDir2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->touch ("/testDFFileDir/toto");
|
||||
$res = $file->is_dir ("//testDFFileDir/toto");
|
||||
@@ -406,7 +419,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testIsFile1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->touch ("/testDFFileDir/toto");
|
||||
$res = $file->is_file ("/testDFFileDir/toto");
|
||||
@@ -415,7 +428,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testIsFile2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->touch ("/testDFFileDir/toto");
|
||||
$res = $file->is_file ("//testDFFileDir");
|
||||
@@ -424,7 +437,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testMkdir5 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
// The parent doesn't exists and not recursive mode : exception
|
||||
$this->expectException ();
|
||||
@@ -433,7 +446,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testMkdir6 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->mkdir ("/testDFFileDir/tptp/titi/poo", 0777, true);
|
||||
$this->assertSame ($res, true);
|
||||
@@ -441,7 +454,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_glob_1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->glob ("/testDFFileDir/*");
|
||||
$this->assertSame ($res, array ("/testDFFileDir/toto",
|
||||
@@ -450,7 +463,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_glob_2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->chdir ("/testDFFileDir");
|
||||
$res = $file->glob ("*");
|
||||
@@ -460,7 +473,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_glob_3 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->chdir ("/testDFFileDir");
|
||||
$res = $file->glob ("/testDFFileDir/*");
|
||||
@@ -470,7 +483,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_glob_4 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$res = $file->glob ("/tmp/testDFFileDir/*");
|
||||
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
||||
"/tmp/testDFFileDir/tptp"));
|
||||
@@ -478,7 +491,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_glob_5 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("/tmp/testDFFileDir");
|
||||
$res = $file->glob ("*");
|
||||
$this->assertSame ($res, array ("toto",
|
||||
@@ -487,7 +500,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_glob_6 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file = new File ();
|
||||
$file->chdir ("/tmp/testDFFileDir");
|
||||
$res = $file->glob ("/tmp/testDFFileDir/*");
|
||||
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
||||
|
||||
Reference in New Issue
Block a user