Commit e4322bb4 authored by totten's avatar totten
Browse files

Store 'permission' property for each form

parent 9500d0c7
......@@ -138,6 +138,7 @@ class CRM_Afform_AfformScanner {
'title' => '',
'description' => '',
'is_public' => FALSE,
'permission' => 'access CiviCRM',
];
$metaFile = $this->findFilePath($name, self::METADATA_FILE);
......
......@@ -107,6 +107,9 @@ class Afform extends AbstractEntity {
[
'name' => 'server_route',
],
[
'name' => 'permission',
],
[
'name' => 'layout',
],
......
{"server_route": "civicrm/mock-page", "requires":["extraMock"]}
{"server_route": "civicrm/mock-page", "requires":["extraMock"], "permission": "access Foobar" }
......@@ -30,10 +30,10 @@ class api_v4_AfformTest extends api_v4_AfformTestCase {
public function getBasicDirectives() {
return [
['mockPage', ['title' => '', 'description' => '', 'server_route' => 'civicrm/mock-page']],
['mockBareFile', ['title' => '', 'description' => '']],
['mockFoo', ['title' => '', 'description' => '']],
['mock-weird-name', ['title' => 'Weird Name', 'description' => '']],
['mockPage', ['title' => '', 'description' => '', 'server_route' => 'civicrm/mock-page', 'permission' => 'access Foobar']],
['mockBareFile', ['title' => '', 'description' => '', 'permission' => 'access CiviCRM']],
['mockFoo', ['title' => '', 'description' => '', 'permission' => 'access CiviCRM']],
['mock-weird-name', ['title' => 'Weird Name', 'description' => '', 'permission' => 'access CiviCRM']],
];
}
......@@ -58,6 +58,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase {
$this->assertEquals($get($originalMetadata, 'title'), $get($result[0], 'title'), $message);
$this->assertEquals($get($originalMetadata, 'description'), $get($result[0], 'description'), $message);
$this->assertEquals($get($originalMetadata, 'server_route'), $get($result[0], 'server_route'), $message);
$this->assertEquals($get($originalMetadata, 'permission'), $get($result[0], 'permission'), $message);
$this->assertTrue(is_array($result[0]['layout']), $message);
$this->assertEquals(TRUE, $get($result[0], 'has_packaged'), $message);
$this->assertEquals(FALSE, $get($result[0], 'has_local'), $message);
......@@ -66,6 +67,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase {
$result = Civi\Api4\Afform::update()
->addWhere('name', '=', $formName)
->addValue('description', 'The temporary description')
->addValue('permission', 'access foo')
->execute();
$this->assertEquals($formName, $result[0]['name'], $message);
$this->assertEquals('The temporary description', $result[0]['description'], $message);
......@@ -76,6 +78,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase {
$this->assertEquals($get($originalMetadata, 'title'), $get($result[0], 'title'), $message);
$this->assertEquals('The temporary description', $get($result[0], 'description'), $message);
$this->assertEquals($get($originalMetadata, 'server_route'), $get($result[0], 'server_route'), $message);
$this->assertEquals('access foo', $get($result[0], 'permission'), $message);
$this->assertTrue(is_array($result[0]['layout']), $message);
$this->assertEquals(TRUE, $get($result[0], 'has_packaged'), $message);
$this->assertEquals(TRUE, $get($result[0], 'has_local'), $message);
......@@ -87,6 +90,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase {
$this->assertEquals($get($originalMetadata, 'title'), $get($result[0], 'title'), $message);
$this->assertEquals($get($originalMetadata, 'description'), $get($result[0], 'description'), $message);
$this->assertEquals($get($originalMetadata, 'server_route'), $get($result[0], 'server_route'), $message);
$this->assertEquals($get($originalMetadata, 'permission'), $get($result[0], 'permission'), $message);
$this->assertTrue(is_array($result[0]['layout']), $message);
$this->assertEquals(TRUE, $get($result[0], 'has_packaged'), $message);
$this->assertEquals(FALSE, $get($result[0], 'has_local'), $message);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment