public function get_contacts(){ $jinput = JFactory::getApplication()->input; header('Content-Type: application/json'); $user = trim($jinput->getString("user")); $contactPhones = $jinput->get('contact_phones', array(), 'ARRAY'); $contactNames = $jinput->get('contact_names', array(), 'ARRAY'); require_once dirname(__FILE__).'/classes/PhonesService.php'; $phonesService = new PhonesService(); echo(json_encode($phonesService->findExistingContacts($user, $contactNames, $contactPhones))); exit; }
public function testMultiplePhoneExistingContact() { $openFireService = $this->getMockBuilder('OpenFireService') ->disableOriginalConstructor() ->setMethods(array('filterContacts')) ->getMock(); $openFireService->expects($this->once()) ->method('filterContacts') ->with($this->equalTo(array('375333333333', '375293333333')), $this->equalTo('375333456789')) ->will($this->returnValue(array("375293333333"))); $phonesService = new PhonesService($openFireService); $result = $phonesService->findExistingContacts("375333456789", array("test"), array("375333333333=375293333333")); $this->assertEquals("OK", $result["status"]); $this->assertEquals(Array ( Array ( "phone" => Array(375333333333, 375293333333), "name" => "test", "phoneCanonical" => Array(375333333333, 375293333333), "jabberUsername" => '*****@*****.**', "contactAdded" => false, "contactExists" => true ) ), $result["contacts"]); }