-
-
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
827e23b
commit 6a14095
Showing
10 changed files
with
183 additions
and
41 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
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
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
<?php | ||
|
||
namespace Civi\Financialacls; | ||
|
||
use Civi\Api4\EntityFinancialAccount; | ||
|
||
// 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\Api4\FinancialAccount; | ||
|
||
// 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. | ||
* | ||
* @throws \API_Exception | ||
*/ | ||
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