2 require_once 'CiviTest/CiviCaseTestCase.php';
5 * Class CRM_Case_XMLProcessorTest
8 class CRM_Case_XMLProcessorTest
extends CiviCaseTestCase
{
10 public function setUp(): void
{
13 $this->processor
= new CRM_Case_XMLProcessor();
17 * Test that allRelationshipTypes() doesn't have name and label mixed up
18 * and that is has the right directions.
20 public function testAllRelationshipTypes() {
22 // Add a relationship type to test against.
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',
32 $result = $this->callAPISuccess('relationship_type', 'create', $params);
33 $relationshipTypeID = $result['id'];
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"]);
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"]);
48 $this->callAPISuccess('relationship_type', 'delete', ['id' => $relationshipTypeID]);