mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-09 13:36:07 +09:00
removed System\Service->staffHasPermissions()
it is just router for Staff\Service\hasPermission()
This commit is contained in:
1 parent
f8783690eb
commit
08524b0f99
4 files changed
+13
-28
No files matched your search
@@ -146,7 +146,8 @@ class Admin extends \Api_Abstract
|
||||
}
|
||||
|
||||
$f = isset($data['f']) ? $data['f'] : null;
|
||||
return $this->getService()->staffHasPermissions($this->getIdentity(), $data['mod'], $f);
|
||||
$service = $this->di['mod_service']('Staff');
|
||||
return $service->hasPermission($this->getIdentity(), $data['mod'], $f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -360,12 +360,6 @@ class Service
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function staffHasPermissions($identity, $module, $f = null)
|
||||
{
|
||||
$service = $this->di['mod_service']('staff');
|
||||
return $service->hasPermission($identity, $module, $f);
|
||||
}
|
||||
|
||||
public function getCurrentUrl()
|
||||
{
|
||||
$request = $this->di['request'];
|
||||
|
||||
@@ -189,12 +189,19 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
|
||||
'mod' => 'extension',
|
||||
);
|
||||
|
||||
$servuceMock = $this->getMockBuilder('\Box\Mod\System\Service')->getMock();
|
||||
$servuceMock->expects($this->atLeastOnce())
|
||||
->method('staffHasPermissions')
|
||||
$staffServiceMock = $this->getMockBuilder('\Box\Mod\Staff\Service')->getMock();
|
||||
$staffServiceMock->expects($this->atLeastOnce())
|
||||
->method('hasPermission')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->api->setService($servuceMock);
|
||||
$di = new \Box_Di();
|
||||
$di['mod_service'] = $di->protect(function($serviceName) use($staffServiceMock){
|
||||
if ($serviceName == 'Staff'){
|
||||
return $staffServiceMock;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$this->api->setDi($di);
|
||||
|
||||
$result = $this->api->is_allowed($data);
|
||||
$this->assertInternalType('bool', $result);
|
||||
|
||||
@@ -299,23 +299,6 @@ class ServiceTest extends \PHPUnit_Framework_TestCase {
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function teststaffHasPermissions()
|
||||
{
|
||||
|
||||
$staffServiceMock = $this->getMockBuilder('\Box\Mod\Staff\Service')->getMock();
|
||||
$staffServiceMock->expects($this->atLeastOnce())
|
||||
->method('hasPermission')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['mod_service'] = $di->protect(function () use($staffServiceMock) {return $staffServiceMock;});
|
||||
|
||||
$this->service->setDi($di);
|
||||
$result = $this->service->staffHasPermissions(new \Model_Client(), 'extension');
|
||||
$this->assertInternalType('bool', $result);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testgetCurrentUrl()
|
||||
{
|
||||
$requestMock = $this->getMockBuilder('\Box_Request')->getMock();
|
||||
|
||||
Reference in new issue
Block a user