1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Nekland\PlacesApi\Api; |
4
|
|
|
|
5
|
|
|
use Nekland\BaseApi\Http\AbstractHttpClient; |
6
|
|
|
use PhpSpec\ObjectBehavior; |
7
|
|
|
use Prophecy\Argument; |
8
|
|
|
|
9
|
|
|
class SearchSpec extends ObjectBehavior |
10
|
|
|
{ |
11
|
|
|
function it_is_initializable() |
12
|
|
|
{ |
13
|
|
|
$this->shouldHaveType('Nekland\PlacesApi\Api\Search'); |
14
|
|
|
$this->shouldHaveType('Nekland\BaseApi\Api\AbstractApi'); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
function let(AbstractHttpClient $client) |
18
|
|
|
{ |
19
|
|
|
$this->beConstructedWith($client); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
function it_should_generate_iterator() |
23
|
|
|
{ |
24
|
|
|
$this->getSearchIterator('42.899798798,43.7234234', '100')->shouldHaveType('Nekland\PlacesApi\Iterator\SearchIterator'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
function it_should_return_result_of_search(AbstractHttpClient $client) |
28
|
|
|
{ |
29
|
|
|
$client->send(Argument::cetera())->willReturn(' |
30
|
|
|
|
31
|
|
|
{ |
32
|
|
|
"html_attributions" : [], |
33
|
|
|
"results" : [ |
34
|
|
|
{ |
35
|
|
|
"geometry" : { |
36
|
|
|
"location" : { |
37
|
|
|
"lat" : -33.870775, |
38
|
|
|
"lng" : 151.199025 |
39
|
|
|
} |
40
|
|
|
}, |
41
|
|
|
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/travel_agent-71.png", |
42
|
|
|
"id" : "21a0b251c9b8392186142c798263e289fe45b4aa", |
43
|
|
|
"name" : "Rhythmboat Cruises", |
44
|
|
|
"opening_hours" : { |
45
|
|
|
"open_now" : true |
46
|
|
|
}, |
47
|
|
|
"photos" : [ |
48
|
|
|
{ |
49
|
|
|
"height" : 270, |
50
|
|
|
"html_attributions" : [], |
51
|
|
|
"photo_reference" : "CnRnAAAAF-LjFR1ZV93eawe1cU_3QNMCNmaGkowY7CnOf-kcNmPhNnPEG9W979jOuJJ1sGr75rhD5hqKzjD8vbMbSsRnq_Ni3ZIGfY6hKWmsOf3qHKJInkm4h55lzvLAXJVc-Rr4kI9O1tmIblblUpg2oqoq8RIQRMQJhFsTr5s9haxQ07EQHxoUO0ICubVFGYfJiMUPor1GnIWb5i8", |
52
|
|
|
"width" : 519 |
53
|
|
|
} |
54
|
|
|
], |
55
|
|
|
"place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk", |
56
|
|
|
"scope" : "GOOGLE", |
57
|
|
|
"alt_ids" : [ |
58
|
|
|
{ |
59
|
|
|
"place_id" : "D9iJyWEHuEmuEmsRm9hTkapTCrk", |
60
|
|
|
"scope" : "APP" |
61
|
|
|
} |
62
|
|
|
], |
63
|
|
|
"reference" : "CoQBdQAAAFSiijw5-cAV68xdf2O18pKIZ0seJh03u9h9wk_lEdG-cP1dWvp_QGS4SNCBMk_fB06YRsfMrNkINtPez22p5lRIlj5ty_HmcNwcl6GZXbD2RdXsVfLYlQwnZQcnu7ihkjZp_2gk1-fWXql3GQ8-1BEGwgCxG-eaSnIJIBPuIpihEhAY1WYdxPvOWsPnb2-nGb6QGhTipN0lgaLpQTnkcMeAIEvCsSa0Ww", |
64
|
|
|
"types" : [ "travel_agency", "restaurant", "food", "establishment" ], |
65
|
|
|
"vicinity" : "Pyrmont Bay Wharf Darling Dr, Sydney" |
66
|
|
|
}, |
67
|
|
|
{ |
68
|
|
|
"geometry" : { |
69
|
|
|
"location" : { |
70
|
|
|
"lat" : -33.866891, |
71
|
|
|
"lng" : 151.200814 |
72
|
|
|
} |
73
|
|
|
}, |
74
|
|
|
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", |
75
|
|
|
"id" : "45a27fd8d56c56dc62afc9b49e1d850440d5c403", |
76
|
|
|
"name" : "Private Charter Sydney Habour Cruise", |
77
|
|
|
"photos" : [ |
78
|
|
|
{ |
79
|
|
|
"height" : 426, |
80
|
|
|
"html_attributions" : [], |
81
|
|
|
"photo_reference" : "CnRnAAAAL3n0Zu3U6fseyPl8URGKD49aGB2Wka7CKDZfamoGX2ZTLMBYgTUshjr-MXc0_O2BbvlUAZWtQTBHUVZ-5Sxb1-P-VX2Fx0sZF87q-9vUt19VDwQQmAX_mjQe7UWmU5lJGCOXSgxp2fu1b5VR_PF31RIQTKZLfqm8TA1eynnN4M1XShoU8adzJCcOWK0er14h8SqOIDZctvU", |
82
|
|
|
"width" : 640 |
83
|
|
|
} |
84
|
|
|
], |
85
|
|
|
"place_id" : "ChIJqwS6fjiuEmsRJAMiOY9MSms", |
86
|
|
|
"scope" : "GOOGLE", |
87
|
|
|
"reference" : "CpQBhgAAAFN27qR_t5oSDKPUzjQIeQa3lrRpFTm5alW3ZYbMFm8k10ETbISfK9S1nwcJVfrP-bjra7NSPuhaRulxoonSPQklDyB-xGvcJncq6qDXIUQ3hlI-bx4AxYckAOX74LkupHq7bcaREgrSBE-U6GbA1C3U7I-HnweO4IPtztSEcgW09y03v1hgHzL8xSDElmkQtRIQzLbyBfj3e0FhJzABXjM2QBoUE2EnL-DzWrzpgmMEulUBLGrtu2Y", |
88
|
|
|
"types" : [ "restaurant", "food", "establishment" ], |
89
|
|
|
"vicinity" : "Australia" |
90
|
|
|
}, |
91
|
|
|
{ |
92
|
|
|
"geometry" : { |
93
|
|
|
"location" : { |
94
|
|
|
"lat" : -33.870943, |
95
|
|
|
"lng" : 151.190311 |
96
|
|
|
} |
97
|
|
|
}, |
98
|
|
|
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", |
99
|
|
|
"id" : "30bee58f819b6c47bd24151802f25ecf11df8943", |
100
|
|
|
"name" : "Bucks Party Cruise", |
101
|
|
|
"opening_hours" : { |
102
|
|
|
"open_now" : true |
103
|
|
|
}, |
104
|
|
|
"photos" : [ |
105
|
|
|
{ |
106
|
|
|
"height" : 600, |
107
|
|
|
"html_attributions" : [], |
108
|
|
|
"photo_reference" : "CnRnAAAA48AX5MsHIMiuipON_Lgh97hPiYDFkxx_vnaZQMOcvcQwYN92o33t5RwjRpOue5R47AjfMltntoz71hto40zqo7vFyxhDuuqhAChKGRQ5mdO5jv5CKWlzi182PICiOb37PiBtiFt7lSLe1SedoyrD-xIQD8xqSOaejWejYHCN4Ye2XBoUT3q2IXJQpMkmffJiBNftv8QSwF4", |
109
|
|
|
"width" : 800 |
110
|
|
|
} |
111
|
|
|
], |
112
|
|
|
"place_id" : "ChIJLfySpTOuEmsRsc_JfJtljdc", |
113
|
|
|
"scope" : "GOOGLE", |
114
|
|
|
"reference" : "CoQBdQAAANQSThnTekt-UokiTiX3oUFT6YDfdQJIG0ljlQnkLfWefcKmjxax0xmUpWjmpWdOsScl9zSyBNImmrTO9AE9DnWTdQ2hY7n-OOU4UgCfX7U0TE1Vf7jyODRISbK-u86TBJij0b2i7oUWq2bGr0cQSj8CV97U5q8SJR3AFDYi3ogqEhCMXjNLR1k8fiXTkG2BxGJmGhTqwE8C4grdjvJ0w5UsAVoOH7v8HQ", |
115
|
|
|
"types" : [ "restaurant", "food", "establishment" ], |
116
|
|
|
"vicinity" : "37 Bank St, Pyrmont" |
117
|
|
|
}, |
118
|
|
|
{ |
119
|
|
|
"geometry" : { |
120
|
|
|
"location" : { |
121
|
|
|
"lat" : -33.867591, |
122
|
|
|
"lng" : 151.201196 |
123
|
|
|
} |
124
|
|
|
}, |
125
|
|
|
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/travel_agent-71.png", |
126
|
|
|
"id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d", |
127
|
|
|
"name" : "Australian Cruise Group", |
128
|
|
|
"opening_hours" : { |
129
|
|
|
"open_now" : true |
130
|
|
|
}, |
131
|
|
|
"photos" : [ |
132
|
|
|
{ |
133
|
|
|
"height" : 242, |
134
|
|
|
"html_attributions" : [], |
135
|
|
|
"photo_reference" : "CnRnAAAABjeoPQ7NUU3pDitV4Vs0BgP1FLhf_iCgStUZUr4ZuNqQnc5k43jbvjKC2hTGM8SrmdJYyOyxRO3D2yutoJwVC4Vp_dzckkjG35L6LfMm5sjrOr6uyOtr2PNCp1xQylx6vhdcpW8yZjBZCvVsjNajLBIQ-z4ttAMIc8EjEZV7LsoFgRoU6OrqxvKCnkJGb9F16W57iIV4LuM", |
136
|
|
|
"width" : 200 |
137
|
|
|
} |
138
|
|
|
], |
139
|
|
|
"place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0", |
140
|
|
|
"scope" : "GOOGLE", |
141
|
|
|
"reference" : "CoQBeQAAAFvf12y8veSQMdIMmAXQmus1zqkgKQ-O2KEX0Kr47rIRTy6HNsyosVl0CjvEBulIu_cujrSOgICdcxNioFDHtAxXBhqeR-8xXtm52Bp0lVwnO3LzLFY3jeo8WrsyIwNE1kQlGuWA4xklpOknHJuRXSQJVheRlYijOHSgsBQ35mOcEhC5IpbpqCMe82yR136087wZGhSziPEbooYkHLn9e5njOTuBprcfVw", |
142
|
|
|
"types" : [ "travel_agency", "restaurant", "food", "establishment" ], |
143
|
|
|
"vicinity" : "32 The Promenade, King Street Wharf 5, Sydney" |
144
|
|
|
} |
145
|
|
|
], |
146
|
|
|
"status" : "OK" |
147
|
|
|
}'); |
148
|
|
|
$this->searchLocation('42.899798798,43.7234234', '100')->shouldContainsResult(); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
|
152
|
|
|
|
153
|
|
|
public function getMatchers() |
154
|
|
|
{ |
155
|
|
|
return [ |
156
|
|
|
'containsResult' => function ($subject) { |
157
|
|
|
return !empty($subject['results']); |
158
|
|
|
} |
159
|
|
|
]; |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|