Merge pull request #14222 from mfb/debug-var
[civicrm-core.git] / tests / phpunit / CRM / UF / Page / ProfileEditorTest.php
1 <?php
2
3 /**
4 * Class CRM_UF_Page_ProfileEditorTest
5 * @group headless
6 */
7 class CRM_UF_Page_ProfileEditorTest extends CiviUnitTestCase {
8
9 public function setUp() {
10 parent::setUp();
11 }
12
13 /**
14 * Spot check a few fields that should appear in schema.
15 */
16 public function testGetSchema() {
17 $schema = CRM_UF_Page_ProfileEditor::getSchema(['IndividualModel', 'ActivityModel']);
18 foreach ($schema as $entityName => $entityDef) {
19 foreach ($entityDef['schema'] as $fieldName => $fieldDef) {
20 $this->assertNotEmpty($fieldDef['type']);
21 $this->assertNotEmpty($fieldDef['title']);
22 $this->assertNotEmpty($fieldDef['civiFieldType']);
23 }
24 }
25
26 $this->assertEquals('Individual', $schema['IndividualModel']['schema']['first_name']['civiFieldType']);
27 $this->assertTrue(empty($schema['IndividualModel']['schema']['first_name']['civiIsLocation']));
28 $this->assertTrue(empty($schema['IndividualModel']['schema']['first_name']['civiIsPhone']));
29
30 $this->assertEquals('Contact', $schema['IndividualModel']['schema']['street_address']['civiFieldType']);
31 $this->assertNotEmpty($schema['IndividualModel']['schema']['street_address']['civiIsLocation']);
32 $this->assertTrue(empty($schema['IndividualModel']['schema']['street_address']['civiIsPhone']));
33
34 $this->assertEquals('Contact', $schema['IndividualModel']['schema']['phone_and_ext']['civiFieldType']);
35 $this->assertNotEmpty($schema['IndividualModel']['schema']['phone_and_ext']['civiIsLocation']);
36 $this->assertNotEmpty($schema['IndividualModel']['schema']['phone_and_ext']['civiIsPhone']);
37
38 $this->assertEquals('Activity', $schema['ActivityModel']['schema']['activity_subject']['civiFieldType']);
39 $this->assertTrue(empty($schema['ActivityModel']['schema']['activity_subject']['civiIsLocation']));
40 $this->assertTrue(empty($schema['ActivityModel']['schema']['activity_subject']['civiIsPhone']));
41
42 // don't mix up contacts and activities
43 $this->assertTrue(empty($schema['IndividualModel']['schema']['activity_subject']));
44 $this->assertTrue(empty($schema['ActivityModel']['schema']['street_address']));
45
46 }
47
48 }