From f9a6cd03982c619cf8b6931bdc45f1df9a095158 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 11 Feb 2019 14:53:49 -0800 Subject: [PATCH] Add skeletal APIs for AfformPalette and AfformTag --- ext/afform/core/Civi/Api4/AfformPalette.php | 46 +++++++++++++++++++ ext/afform/core/Civi/Api4/AfformTag.php | 45 ++++++++++++++++++ .../phpunit/api/v4/AfformPaletteTest.php | 24 ++++++++++ 3 files changed, 115 insertions(+) create mode 100644 ext/afform/core/Civi/Api4/AfformPalette.php create mode 100644 ext/afform/core/Civi/Api4/AfformTag.php create mode 100644 ext/afform/mock/tests/phpunit/api/v4/AfformPaletteTest.php diff --git a/ext/afform/core/Civi/Api4/AfformPalette.php b/ext/afform/core/Civi/Api4/AfformPalette.php new file mode 100644 index 0000000000..ad0534f12b --- /dev/null +++ b/ext/afform/core/Civi/Api4/AfformPalette.php @@ -0,0 +1,46 @@ + 'Parent:afl-name', + 'entity' => 'Parent', + 'title' => 'Name', + 'template' => '', + ], + [ + 'id' => 'Parent:afl-address', + 'entity' => 'Parent', + 'title' => 'Address', + 'template' => '', + ], + ]; + }); + } + + /** + * @return array + */ + public static function permissions() { + return [ + "meta" => ["access CiviCRM"], + "default" => ["administer CiviCRM"], + ]; + } + +} diff --git a/ext/afform/core/Civi/Api4/AfformTag.php b/ext/afform/core/Civi/Api4/AfformTag.php new file mode 100644 index 0000000000..763664e11b --- /dev/null +++ b/ext/afform/core/Civi/Api4/AfformTag.php @@ -0,0 +1,45 @@ + 'afl-entity', + 'attrs' => ['entity-name', 'matching-rule', 'assigned-values'], + ], + [ + 'name' => 'afl-name', + 'attrs' => ['contact-id', 'afl-label'], + ], + [ + 'name' => 'afl-contact-email', + 'attrs' => ['contact-id', 'afl-label'], + ], + ]; + }); + } + + /** + * @return array + */ + public static function permissions() { + return [ + "meta" => ["access CiviCRM"], + "default" => ["administer CiviCRM"], + ]; + } + +} diff --git a/ext/afform/mock/tests/phpunit/api/v4/AfformPaletteTest.php b/ext/afform/mock/tests/phpunit/api/v4/AfformPaletteTest.php new file mode 100644 index 0000000000..c181150bbd --- /dev/null +++ b/ext/afform/mock/tests/phpunit/api/v4/AfformPaletteTest.php @@ -0,0 +1,24 @@ +addWhere('id', '=', 'Parent:afl-name') + ->execute(); + $this->assertEquals(1, $r->count()); + + $r = Civi\Api4\AfformPalette::get() + ->setLimit(10) + ->execute(); + $this->assertTrue($r->count() > 1); + } + +} -- 2.25.1