protected function checkFields($entityName) {
$fields = civicrm_api4($entityName, 'getFields', [
'checkPermissions' => FALSE,
+ 'action' => 'create',
'where' => [['type', '=', 'Field']],
])->indexBy('name');
// Hmm, not true of every primary key... what about Afform.name?
$this->assertEquals('Integer', $fields[$idField]['data_type']);
+ // The underlying schema is not 100% consistent, but this is the standard in APIv4
+ if (isset($fields['is_active'])) {
+ $this->assertTrue($fields['is_active']['default_value']);
+ $this->assertFalse($fields['is_active']['required']);
+ }
+
// Ensure that the getFields (FieldSpec) format is generally consistent.
foreach ($fields as $field) {
$isNotNull = function($v) {
$this->assertContains('foo', $fieldNames);
}
- public function testIsActiveFieldCanDefaultToFalse(): void {
- $gatherer = new SpecGatherer();
- // Use Dashboard as it has is_active field and that defaults to 0 (according to schema)
- $specs = $gatherer->getSpec('Dashboard', 'create', FALSE);
- self::assertFalse($specs->getFieldByName('is_active')->getDefaultValue(), 'Default value for "is_active" field is not false');
- }
-
}