From ac8aaa49f1dbada7ae0440c87937bb004ebd3b86 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 2 Aug 2013 23:47:10 +1200 Subject: [PATCH] CRM-13149 additional test on api array as filter syntax --- tests/phpunit/api/v3/RelationshipTest.php | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/phpunit/api/v3/RelationshipTest.php b/tests/phpunit/api/v3/RelationshipTest.php index f3e31f18f9..c2c864b6ad 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -924,5 +924,43 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { $this->assertTrue(in_array($value['relationship_type_id'], array($this->_relTypeID, $relType3))); } } + + /** + * Checks that passing in 'contact_id_b' + a relationship type + * will filter by relationship type for contact b + * + * We should get 1 result without or with correct relationship type id & 0 with + * an incorrect one + */ + function testGetRelationshipByTypeArrayReciprocal() { + $created = $this->callAPISuccess($this->_entity, 'create', $this->_params); + $org3 = $this->organizationCreate(); + $relType2 = 5; // lets just assume built in ones aren't being messed with! + $relType3 = 6; // lets just assume built in ones aren't being messed with! + + //relationshp 2 + $this->callAPISuccess($this->_entity, 'create', + array_merge($this->_params, array( + 'relationship_type_id' => $relType2, + 'contact_id_b' => $this->_cId_b2)) + ); + + //relationshp 3 + $this->callAPISuccess($this->_entity, 'create', + array_merge($this->_params, array( + 'relationship_type_id' => $relType3, + 'contact_id_b' => $org3)) + ); + + $result = $this->callAPISuccess($this->_entity, 'get', array( + 'contact_id' => $this->_cId_a, + 'relationship_type_id' => array('IN' => array($this->_relTypeID, $relType3)), + )); + + $this->assertEquals(2, $result['count']); + foreach ($result['values'] as $key => $value) { + $this->assertTrue(in_array($value['relationship_type_id'], array($this->_relTypeID, $relType3))); + } + } } -- 2.25.1