From 3a4658a1b950b9db16a315119a94bc3bd6ab9bd1 Mon Sep 17 00:00:00 2001 From: colemanw Date: Wed, 27 Sep 2023 12:19:09 -0400 Subject: [PATCH] APIv4 - Delete unnecessary contact spec provider --- .../Provider/ContactCreationSpecProvider.php | 41 ------------------- tests/phpunit/api/v4/Action/GetFieldsTest.php | 2 + 2 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 Civi/Api4/Service/Spec/Provider/ContactCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/ContactCreationSpecProvider.php b/Civi/Api4/Service/Spec/Provider/ContactCreationSpecProvider.php deleted file mode 100644 index 15cb41cafd..0000000000 --- a/Civi/Api4/Service/Spec/Provider/ContactCreationSpecProvider.php +++ /dev/null @@ -1,41 +0,0 @@ -getFieldByName('is_opt_out')->setRequired(FALSE); - $spec->getFieldByName('is_deleted')->setRequired(FALSE); - } - - /** - * @param string $entity - * @param string $action - * - * @return bool - */ - public function applies($entity, $action) { - return $entity === 'Contact' && $action === 'create'; - } - -} diff --git a/tests/phpunit/api/v4/Action/GetFieldsTest.php b/tests/phpunit/api/v4/Action/GetFieldsTest.php index becf8e1027..b12e26e068 100644 --- a/tests/phpunit/api/v4/Action/GetFieldsTest.php +++ b/tests/phpunit/api/v4/Action/GetFieldsTest.php @@ -60,6 +60,7 @@ class GetFieldsTest extends Api4TestBase implements TransactionalInterface { public function testContactGetFields(): void { $fields = Contact::getFields(FALSE) + ->setAction('create') ->execute() ->indexBy('name'); // Ensure table & column are returned @@ -71,6 +72,7 @@ class GetFieldsTest extends Api4TestBase implements TransactionalInterface { $this->assertEquals(['name', 'label', 'icon'], $fields['contact_sub_type']['suffixes']); // Check `required` and `nullable` + $this->assertFalse($fields['is_opt_out']['required']); $this->assertFalse($fields['is_deleted']['required']); $this->assertFalse($fields['is_deleted']['nullable']); $this->assertFalse($fields['id']['nullable']); -- 2.25.1