Update Tests to supports namespaces

This commit is contained in:
2021-05-07 16:55:38 +02:00
parent ccf0f47c7f
commit 55530b055c
49 changed files with 82 additions and 64 deletions

View File

@@ -0,0 +1,63 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework\Tests;
/** Test the authhtpasswd.php file */
class authhtpasswdTest extends \PHPUnit_Framework_TestCase
{
public function test_clean ()
{
@unlink ("/tmp/htpasswd.file");
file_put_contents ("/tmp/htpasswd.file",
'toto@toto.com:$2y$05$dO7qyX4simzg3pMgWyqHgeAjFauXEyUdPdyrwDMVNj4fTuE24TGuq'
."\n".
'titi@titi.com:$2y$05$dO7qyX4simzg3pMgWyqHgeAjFauXEyUdPdyrwDMVNj4fTuE24TGuq'
."\n"
);
}
public function test_connect ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$res = $authhtpasswd->connect ();
$this->assertSame ($res, null);
}
public function test_authentication1 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$res = $authhtpasswd->authentication ("toto@toto.com", "toto123");
$this->assertSame ($res, true);
}
public function test_authentication2 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$this->setExpectedException ("Exception");
$res = $authhtpasswd->authentication ("UNKNOWN@toto.com", "toto123");
}
public function test_authentication3 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$this->setExpectedException ("Exception");
$res = $authhtpasswd->authentication ("toto@toto.com", "BAD PASSWD");
}
public function test_authentication4 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$res = $authhtpasswd->authentication ("titi@titi.com", "toto123");
$this->assertSame ($res, true);
}
}