+++ /dev/null
-<?php
-
-/*
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC. All rights reserved. |
- | |
- | This work is published under the GNU AGPLv3 license with some |
- | permitted exceptions and without any warranty. For full license |
- | and copyright information, see https://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-namespace Civi\Api4\Service\Spec\Provider;
-
-use Civi\Api4\Service\Spec\RequestSpec;
-
-/**
- * @service
- * @internal
- */
-class ContactCreationSpecProvider extends \Civi\Core\Service\AutoService implements Generic\SpecProviderInterface {
-
- /**
- * @param \Civi\Api4\Service\Spec\RequestSpec $spec
- */
- public function modifySpec(RequestSpec $spec) {
- $spec->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';
- }
-
-}
public function testContactGetFields(): void {
$fields = Contact::getFields(FALSE)
+ ->setAction('create')
->execute()
->indexBy('name');
// Ensure table & column are returned
$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']);