public function testGetAddressFromSource() { $source = array("first-name" => "Obi Wan", "last-name" => "Kenobi", "full-name" => "Obi Wan Kenobi", "city" => "New York", "state" => "New York", "address" => "1140 Park Avenue", "zip" => "10128", "email" => "*****@*****.**"); $address = get_address_from_source($source); $expected_address = $source['address'] . " " . $source['city'] . ", " . $source['state']; $this->assertEquals($expected_address, $address); }
function get_all_friends($config) { $client = ClientBuilder::create()->build(); $params = []; $params['index'] = 'friends'; $params['type'] = 'friends'; $params['size'] = 1000; $params['body']['query']['match_all'] = [$_GET['search']]; $params['body']['sort'] = ['_score']; $result = $client->search($params)['hits']['hits']; $sources = array_map(function ($arr) { return $arr['_source']; }, $result); $current_user_location = get_address_from_source(extract_current_user($sources, $_SESSION['user_email'])); $config = parse_ini_file('/../../../config.ini'); return array(friends => new ArrayIterator($sources), key => $config['maps_key'], origin => $current_user_location); }