[limb-svn] r6899 - in 3.x/trunk/limb/acl: src tests/cases

svn at limb-project.com svn at limb-project.com
Mon Apr 7 00:53:22 MSD 2008


Author: korchasa
Date: 2008-04-07 00:53:22 +0400 (Mon, 07 Apr 2008)
New Revision: 6899
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6899

Added:
   3.x/trunk/limb/acl/src/lmbResourceProviderInterface.interface.php
   3.x/trunk/limb/acl/src/lmbRoleProviderInterface.interface.php
Modified:
   3.x/trunk/limb/acl/src/lmbAcl.class.php
   3.x/trunk/limb/acl/tests/cases/lmbAclObjectsFeaturesTest.class.php
Log:
" -- abstract classes for role and resources providers changet for interfaces"

Modified: 3.x/trunk/limb/acl/src/lmbAcl.class.php
===================================================================
--- 3.x/trunk/limb/acl/src/lmbAcl.class.php	2008-04-06 09:41:57 UTC (rev 6898)
+++ 3.x/trunk/limb/acl/src/lmbAcl.class.php	2008-04-06 20:53:22 UTC (rev 6899)
@@ -207,12 +207,12 @@
       if($resolved_role = $resource->getRoleFor($role))
         $role = $resolved_role;
 
-    if($resource instanceof lmbAbstractResourceProvider)
+    if($resource instanceof lmbResourceProviderInterface )
       $resource = $resource->getResource();
 
     $this->_checkResource($resource);
 
-    if($role instanceof lmbAbstractRoleProvider)
+    if($role instanceof lmbRoleProviderInterface)
       $role = $role->getRole();
 
     if(!$this->isRoleExist($role))

Added: 3.x/trunk/limb/acl/src/lmbResourceProviderInterface.interface.php
===================================================================
--- 3.x/trunk/limb/acl/src/lmbResourceProviderInterface.interface.php	                        (rev 0)
+++ 3.x/trunk/limb/acl/src/lmbResourceProviderInterface.interface.php	2008-04-06 20:53:22 UTC (rev 6899)
@@ -0,0 +1,12 @@
+<?php
+/*
+* Limb PHP Framework
+*
+* @link http://limb-project.com
+* @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+* @license    LGPL http://www.gnu.org/copyleft/lesser.html
+*/
+interface lmbResourceProviderInterface
+{
+  function getResource();
+}

Added: 3.x/trunk/limb/acl/src/lmbRoleProviderInterface.interface.php
===================================================================
--- 3.x/trunk/limb/acl/src/lmbRoleProviderInterface.interface.php	                        (rev 0)
+++ 3.x/trunk/limb/acl/src/lmbRoleProviderInterface.interface.php	2008-04-06 20:53:22 UTC (rev 6899)
@@ -0,0 +1,12 @@
+<?php
+/*
+* Limb PHP Framework
+*
+* @link http://limb-project.com
+* @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+* @license    LGPL http://www.gnu.org/copyleft/lesser.html
+*/
+interface lmbRoleProviderInterface
+{
+  function getRole();
+}

Modified: 3.x/trunk/limb/acl/tests/cases/lmbAclObjectsFeaturesTest.class.php
===================================================================
--- 3.x/trunk/limb/acl/tests/cases/lmbAclObjectsFeaturesTest.class.php	2008-04-06 09:41:57 UTC (rev 6898)
+++ 3.x/trunk/limb/acl/tests/cases/lmbAclObjectsFeaturesTest.class.php	2008-04-06 20:53:22 UTC (rev 6899)
@@ -7,17 +7,12 @@
 * @license    LGPL http://www.gnu.org/copyleft/lesser.html
 */
 lmb_require('limb/acl/src/lmbAcl.class.php');
-lmb_require('limb/acl/src/lmbAbstractRoleProvider.class.php');
-lmb_require('limb/acl/src/lmbAbstractResourceProvider.class.php');
+lmb_require('limb/acl/src/lmbRoleProviderInterface.interface.php');
+lmb_require('limb/acl/src/lmbResourceProviderInterface.interface.php');
 lmb_require('limb/acl/src/lmbRolesResolverInterface.interface.php');
 
-class Acl_Tests_Admin extends lmbAbstractRoleProvider
+class Acl_Tests_User implements lmbRoleProviderInterface
 {
-  public $_role = 'admin';
-}
-
-class Acl_Tests_User extends lmbAbstractRoleProvider
-{
   protected $is_logged_in;
   public $name;
 
@@ -35,21 +30,24 @@
   }
 }
 
-class Acl_Tests_Member extends lmbAbstractRoleProvider
+class Acl_Tests_Member implements lmbRoleProviderInterface
 {
-  public $name;
-  protected $_role = 'member';
+  public $name;  
 
   function __construct($name)
   {
     $this->name = $name;
   }
+  
+  function getRole()
+  {
+    return 'member';
+  }
 
 }
 
-class Acl_Tests_Article extends lmbAbstractResourceProvider implements lmbRolesResolverInterface
-{
-  protected $_resource = 'article';
+class Acl_Tests_Article implements lmbRolesResolverInterface, lmbResourceProviderInterface
+{  
 
   function getRoleFor($object)
   {
@@ -58,6 +56,11 @@
     if('Valtazar' === $object->name)
       return 'approver';
   }
+  
+  function getResource()
+  {
+    return 'article';
+  }
 }
 
 class lmbAclObjectsFeatureTest extends UnitTestCase
@@ -69,14 +72,8 @@
     $this->acl = new lmbAcl();
   }
 
-  function testGetRoleDefinedByProperty()
+  function testGetRole()
   {
-    $admin = new Acl_Tests_Admin();
-    $this->assertEqual('admin', $admin->getRole());
-  }
-
-  function testGetRoleFromOverridedMethod()
-  {
     $user = new Acl_Tests_User($is_logged_in = false);
     $this->assertEqual('guest', $user->getRole());
 



More information about the limb-svn mailing list