Commit | Line | Data |
---|---|---|
2058bf54 D |
1 | <?php |
2 | require_once 'CiviTest/CiviCaseTestCase.php'; | |
3 | ||
4 | /** | |
5 | * Class CRM_Case_XMLProcessorTest | |
6 | * @group headless | |
7 | */ | |
8 | class CRM_Case_XMLProcessorTest extends CiviCaseTestCase { | |
9 | ||
5d345864 | 10 | public function setUp(): void { |
2058bf54 D |
11 | parent::setUp(); |
12 | ||
13 | $this->processor = new CRM_Case_XMLProcessor(); | |
14 | } | |
15 | ||
16 | /** | |
17 | * Test that allRelationshipTypes() doesn't have name and label mixed up | |
18 | * and that is has the right directions. | |
19 | */ | |
20 | public function testAllRelationshipTypes() { | |
21 | ||
22 | // Add a relationship type to test against. | |
23 | $params = [ | |
24 | 'contact_type_a' => 'Individual', | |
25 | 'contact_type_b' => 'Individual', | |
26 | 'name_a_b' => 'fpt123a', | |
27 | 'label_a_b' => 'Food poison tester is', | |
28 | 'name_b_a' => 'fpt123b', | |
29 | 'label_b_a' => 'Food poison tester for', | |
30 | 'description' => 'Food poison tester', | |
31 | ]; | |
32 | $result = $this->callAPISuccess('relationship_type', 'create', $params); | |
33 | $relationshipTypeID = $result['id']; | |
34 | ||
35 | // All we can test against is label, so just check A and B are right (or | |
36 | // wrong, depending on your point of view). Let's not use the words right | |
37 | // and wrong let's just call it one way and the other way. | |
38 | $relationshipTypes = $this->processor->allRelationshipTypes(FALSE); | |
39 | $this->assertEquals('Food poison tester is', $relationshipTypes["{$relationshipTypeID}_a_b"]); | |
40 | $this->assertEquals('Food poison tester for', $relationshipTypes["{$relationshipTypeID}_b_a"]); | |
41 | ||
42 | // For true, B and A are the other way around here. | |
43 | $relationshipTypes = $this->processor->allRelationshipTypes(TRUE); | |
44 | $this->assertEquals('Food poison tester is', $relationshipTypes["{$relationshipTypeID}_b_a"]); | |
45 | $this->assertEquals('Food poison tester for', $relationshipTypes["{$relationshipTypeID}_a_b"]); | |
46 | ||
47 | // cleanup | |
48 | $this->callAPISuccess('relationship_type', 'delete', ['id' => $relationshipTypeID]); | |
49 | } | |
50 | ||
51 | } |