[fix] #1545 htaccess files
This commit is contained in:
parent
b2eb4e3016
commit
590223878e
|
@ -35,11 +35,12 @@ reset($_POST);
|
||||||
while (list($key,$val)=each($_POST)) {
|
while (list($key,$val)=each($_POST)) {
|
||||||
if (substr($key,0,4)=="del_") {
|
if (substr($key,0,4)=="del_") {
|
||||||
// Effacement du dossier $val
|
// Effacement du dossier $val
|
||||||
$r=$hta->DelDir($val);
|
// $r=$hta->DelDir($val);
|
||||||
if (!$r) {
|
$return = $hta->DelDir($val);
|
||||||
$error.=$err->errstr()."<br />";
|
if (!$return) {
|
||||||
|
$error.= $err->errstr()."<br />";
|
||||||
} else {
|
} else {
|
||||||
$error.=sprintf(_("The protected folder %s has been successfully unprotected"),$val)."<br />";
|
$error.= sprintf(_("The protected folder %s has been successfully unprotected"),$val)."<br />";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
protected $object;
|
protected $object;
|
||||||
|
|
||||||
|
const PATH_HTACCESS = "/tmp/.htaccess";
|
||||||
|
const PATH_HTPASSWD = "/tmp/.htpasswd";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the fixture, for example, opens a network connection.
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
* This method is called before a test is executed.
|
* This method is called before a test is executed.
|
||||||
|
@ -16,6 +19,10 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
touch(self::PATH_HTACCESS);
|
||||||
|
touch(self::PATH_HTPASSWD);
|
||||||
|
$file_content = "AuthUserFile \"/tmp/.htpasswd\"\nAuthName \"Restricted area\"\nAuthType Basic\nrequire valid-user\n";
|
||||||
|
file_put_contents(self::PATH_HTACCESS,$file_content);
|
||||||
$this->object = new m_hta;
|
$this->object = new m_hta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +33,12 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
if(file_exists(self::PATH_HTACCESS)){
|
||||||
|
unlink (self::PATH_HTACCESS);
|
||||||
|
}
|
||||||
|
if(file_exists(self::PATH_HTPASSWD)){
|
||||||
|
unlink (self::PATH_HTPASSWD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,14 +127,26 @@ class m_htaTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_hta::DelDir
|
* @covers m_hta::DelDir
|
||||||
* @todo Implement testDelDir().
|
|
||||||
*/
|
*/
|
||||||
public function testDelDir()
|
public function testDelDir()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$result = $this->object->DelDir("/tmp",TRUE);
|
||||||
$this->markTestIncomplete(
|
$this->assertTrue($result);
|
||||||
'This test has not been implemented yet.'
|
$this->assertFileNotExists(self::PATH_HTACCESS);
|
||||||
);
|
$this->assertFileNotExists(self::PATH_HTPASSWD);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers m_hta::DelDir
|
||||||
|
*/
|
||||||
|
public function testDelDirNotEmpty()
|
||||||
|
{
|
||||||
|
file_put_contents(self::PATH_HTACCESS, "\nphpunit", FILE_APPEND);
|
||||||
|
$result = $this->object->DelDir("/tmp",TRUE);
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$this->assertFileExists(self::PATH_HTACCESS);
|
||||||
|
$this->assertFileNotExists(self::PATH_HTPASSWD);
|
||||||
|
$this->assertTrue("phpunit" == trim(file_get_contents(self::PATH_HTACCESS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue