Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)
This commit is contained in:
@@ -1,43 +1,46 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
/**
|
||||
* DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework\Tests;
|
||||
|
||||
use Domframework\Authzgroups;
|
||||
|
||||
/** Test the Authzgroups.php file */
|
||||
/**
|
||||
* Test the Authzgroups.php file
|
||||
*/
|
||||
class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $dbconfig = array (
|
||||
private $dbconfig = [
|
||||
"dsn" => "sqlite:/tmp/databaseAuthzGroups.db",
|
||||
"username" => null,
|
||||
"password" => null,
|
||||
"driver_options" => null,
|
||||
"tableprefix" => "",
|
||||
);
|
||||
public function test_Initialization()
|
||||
];
|
||||
public function testInitialization()
|
||||
{
|
||||
if (file_exists("/tmp/databaseAuthzGroups.db")) {
|
||||
unlink("/tmp/databaseAuthzGroups.db");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_createTables1()
|
||||
public function testCreateTables1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$this->setExpectedException("Exception");
|
||||
$authz->createTables();
|
||||
}
|
||||
|
||||
public function test_connect()
|
||||
public function testConnect()
|
||||
{
|
||||
// Must use the model to create the database structure as there is no
|
||||
// creation of tables in controller
|
||||
// Must use the model to create the database structure as there is no
|
||||
// creation of tables in controller
|
||||
$authz = new Authzgroups();
|
||||
$res = $authz->connect(
|
||||
$this->dbconfig["dsn"],
|
||||
@@ -48,7 +51,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
|
||||
public function test_createTables2()
|
||||
public function testCreateTables2()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -64,7 +67,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
////////////////
|
||||
// OBJECT //
|
||||
////////////////
|
||||
public function test_objectCreate1()
|
||||
public function testObjectCreate1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -77,7 +80,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("1", $res);
|
||||
}
|
||||
|
||||
public function test_objectUpdate1()
|
||||
public function testObjectUpdate1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -90,7 +93,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(1, $res);
|
||||
}
|
||||
|
||||
public function test_objectDelete1()
|
||||
public function testObjectDelete1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -99,7 +102,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["password"],
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
// The object was renamed and is not available
|
||||
// The object was renamed and is not available
|
||||
$this->setExpectedException("Exception");
|
||||
$res = $authz->objectDel("MODULE", "/object");
|
||||
}
|
||||
@@ -107,7 +110,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
////////////////
|
||||
// GROUPS //
|
||||
////////////////
|
||||
public function test_groupCreate1()
|
||||
public function testGroupCreate1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -120,7 +123,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("1", $res);
|
||||
}
|
||||
|
||||
public function test_groupUpdate1()
|
||||
public function testGroupUpdate1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -133,7 +136,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(1, $res);
|
||||
}
|
||||
|
||||
public function test_groupDelete1()
|
||||
public function testGroupDelete1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -142,7 +145,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["password"],
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
// The group doesn't exists
|
||||
// The group doesn't exists
|
||||
$this->setExpectedException("Exception");
|
||||
$res = $authz->groupDel("MODULE", "group");
|
||||
}
|
||||
@@ -150,7 +153,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
/////////////////////
|
||||
// GROUPMEMBER //
|
||||
/////////////////////
|
||||
public function test_groupmemberCreate1()
|
||||
public function testGroupmemberCreate1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -159,12 +162,12 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["password"],
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
// The group doesn't exists
|
||||
// The group doesn't exists
|
||||
$this->setExpectedException("Exception");
|
||||
$res = $authz->groupmemberAdd("MODULE", "group", "userKnown");
|
||||
}
|
||||
|
||||
public function test_groupmemberCreate2()
|
||||
public function testGroupmemberCreate2()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -177,7 +180,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("1", $res);
|
||||
}
|
||||
|
||||
public function test_groupmemberDelete1()
|
||||
public function testGroupmemberDelete1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -186,12 +189,12 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["password"],
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
// The group doesn't exists
|
||||
// The group doesn't exists
|
||||
$this->setExpectedException("Exception");
|
||||
$res = $authz->groupmemberDel("MODULE", "group", "userKnown");
|
||||
}
|
||||
|
||||
public function test_groupmemberReadGroup1()
|
||||
public function testGroupmemberReadGroup1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -200,12 +203,12 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["password"],
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
// The group doesn't exists
|
||||
// The group doesn't exists
|
||||
$this->setExpectedException("Exception");
|
||||
$res = $authz->groupmemberReadGroup("MODULE", "group");
|
||||
}
|
||||
|
||||
public function test_groupmemberReadGroup2()
|
||||
public function testGroupmemberReadGroup2()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -215,10 +218,10 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
$res = $authz->groupmemberReadGroup("MODULE", "group2");
|
||||
$this->assertSame(array (array ("user" => "userKnown")), $res);
|
||||
$this->assertSame([["user" => "userKnown"]], $res);
|
||||
}
|
||||
|
||||
public function test_groupmemberReadUser1()
|
||||
public function testGroupmemberReadUser1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -228,13 +231,13 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
$res = $authz->groupmemberReadUser("MODULE", "userKnown");
|
||||
$this->assertSame(array (1 => "group2"), $res);
|
||||
$this->assertSame([1 => "group2"], $res);
|
||||
}
|
||||
|
||||
////////////////
|
||||
// RIGHTS //
|
||||
////////////////
|
||||
public function test_rightCreate1()
|
||||
public function testRightCreate1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -247,7 +250,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("1", $res);
|
||||
}
|
||||
|
||||
public function test_rightUpdate1()
|
||||
public function testRightUpdate1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -260,7 +263,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(1, $res);
|
||||
}
|
||||
|
||||
public function test_rightDelete1()
|
||||
public function testRightDelete1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -269,7 +272,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["password"],
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
// The object doesn't exists
|
||||
// The object doesn't exists
|
||||
$this->setExpectedException("Exception");
|
||||
$res = $authz->rightDel("MODULE", "group2", "/object");
|
||||
}
|
||||
@@ -278,7 +281,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
//////////////////////////////////////////////
|
||||
// CLEANING DATABASE : REMOVING ENTRIES //
|
||||
//////////////////////////////////////////////
|
||||
public function test_deleteGroupmember2()
|
||||
public function testDeleteGroupmember2()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -291,7 +294,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(1, $res);
|
||||
}
|
||||
|
||||
public function test_deleteObject2()
|
||||
public function testDeleteObject2()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -304,7 +307,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(1, $res);
|
||||
}
|
||||
|
||||
public function test_deleteGroup2()
|
||||
public function testDeleteGroup2()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -320,7 +323,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
/////////////////////
|
||||
// USER RIGHTS //
|
||||
/////////////////////
|
||||
public function test_userrightsget1()
|
||||
public function testUserrightsget1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -329,7 +332,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->dbconfig["password"],
|
||||
$this->dbconfig["driver_options"]
|
||||
);
|
||||
// Create infos to tests the userrightsget method
|
||||
// Create infos to tests the userrightsget method
|
||||
$authz->objectAdd("MODULE1", "/");
|
||||
$authz->objectAdd("MODULE1", "/rep1");
|
||||
$authz->objectAdd("MODULE1", "/rep1/rep2");
|
||||
@@ -349,10 +352,10 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$authz->rightAdd("MODULE1", "group3", "/rep1/rep2", "RO");
|
||||
|
||||
$res = $authz->userrightsget("MODULE1", "userKnown");
|
||||
$this->assertSame(array ("/rep1/rep2" => "RW"), $res);
|
||||
$this->assertSame(["/rep1/rep2" => "RW"], $res);
|
||||
}
|
||||
|
||||
public function test_allow1()
|
||||
public function testAllow1()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -365,7 +368,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("RW", $res);
|
||||
}
|
||||
|
||||
public function test_allow2()
|
||||
public function testAllow2()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -379,7 +382,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("RW", $res);
|
||||
}
|
||||
|
||||
public function test_allow3()
|
||||
public function testAllow3()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
@@ -393,7 +396,7 @@ class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("RW", $res);
|
||||
}
|
||||
|
||||
public function test_allow4()
|
||||
public function testAllow4()
|
||||
{
|
||||
$authz = new Authzgroups();
|
||||
$authz->connect(
|
||||
|
||||
Reference in New Issue
Block a user