-
-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use acl, not blanket permissions on FinancialAccount, FinancialType, …
…EntityFinancialAccount
- Loading branch information
1 parent
b2c8e47
commit 2078183
Showing
7 changed files
with
159 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
ext/financialacls/tests/phpunit/Civi/Financialacls/EntityFinancialAccountTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Civi\Financialacls; | ||
|
||
use Civi; | ||
use Civi\Api4\EntityFinancialAccount; | ||
use CRM_Core_Session; | ||
|
||
// I fought the Autoloader and the autoloader won. | ||
require_once 'BaseTestClass.php'; | ||
|
||
/** | ||
* @group headless | ||
*/ | ||
class EntityFinancialAccountTest extends BaseTestClass { | ||
|
||
/** | ||
* Test only accounts with permitted income types can be retrieved. | ||
* | ||
* @throws \API_Exception | ||
*/ | ||
public function testGetEntityFinancialAccount(): void { | ||
$this->setupLoggedInUserWithLimitedFinancialTypeAccess(); | ||
$entityFinancialAccounts = EntityFinancialAccount::get(FALSE)->execute(); | ||
$this->assertCount(23, $entityFinancialAccounts); | ||
$restrictedAccounts = EntityFinancialAccount::get()->execute(); | ||
$this->assertCount(9, $restrictedAccounts); | ||
foreach ($restrictedAccounts as $restrictedAccount) { | ||
if ($restrictedAccount['entity_table'] === 'civicrm_financial_type') { | ||
$this->assertEquals(1, $restrictedAccount['entity_id']); | ||
} | ||
} | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
ext/financialacls/tests/phpunit/Civi/Financialacls/FinancialAccountTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Civi\Financialacls; | ||
|
||
use Civi; | ||
use Civi\Api4\FinancialAccount; | ||
use CRM_Core_Session; | ||
|
||
// I fought the Autoloader and the autoloader won. | ||
require_once 'BaseTestClass.php'; | ||
|
||
/** | ||
* @group headless | ||
*/ | ||
class FinancialAccountTest extends BaseTestClass { | ||
|
||
/** | ||
* Test only accounts with permitted income types can be retrieved. | ||
*/ | ||
public function testGetFinancialAccount(): void { | ||
$this->setupLoggedInUserWithLimitedFinancialTypeAccess(); | ||
$financialAccounts = FinancialAccount::get(FALSE)->execute(); | ||
$this->assertCount(14, $financialAccounts); | ||
$restrictedAccounts = FinancialAccount::get()->execute(); | ||
$this->assertCount(1, $restrictedAccounts); | ||
$this->assertEquals('Donation', $restrictedAccounts[0]['name']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters