@@ 78-104 (lines=27) @@ | ||
75 | } |
|
76 | ||
77 | /** @test */ |
|
78 | function use_general_model_by_default_when_predicting_the_content_of_an_image() |
|
79 | { |
|
80 | $httpClient = $this->sendRequest( |
|
81 | $this->getHttpClientMock(), |
|
82 | 'https://api.clarifai.com/v2/models/'.Models::GENERAL.'/outputs', |
|
83 | [ |
|
84 | [ |
|
85 | 'data' => [ |
|
86 | 'image' => [ |
|
87 | 'url' => 'https://samples.clarifai.com/metro-north.jpg', |
|
88 | ] |
|
89 | ] |
|
90 | ] |
|
91 | ] |
|
92 | ); |
|
93 | ||
94 | $client = new Client($httpClient, 'client-id', 'client-secret'); |
|
95 | ||
96 | $response = $client->withAccessToken('access-token')->predict([ |
|
97 | 'https://samples.clarifai.com/metro-north.jpg', |
|
98 | ]); |
|
99 | ||
100 | $this->assertTrue(is_array($response)); |
|
101 | $this->assertEquals([ |
|
102 | 'foo' => 'bar' |
|
103 | ], $response); |
|
104 | } |
|
105 | ||
106 | /** @test */ |
|
107 | function can_predict_the_content_of_an_image_by_passing_an_url_and_a_specific_model() |
|
@@ 107-133 (lines=27) @@ | ||
104 | } |
|
105 | ||
106 | /** @test */ |
|
107 | function can_predict_the_content_of_an_image_by_passing_an_url_and_a_specific_model() |
|
108 | { |
|
109 | $httpClient = $this->sendRequest( |
|
110 | $this->getHttpClientMock(), |
|
111 | 'https://api.clarifai.com/v2/models/'.Models::FOOD.'/outputs', |
|
112 | [ |
|
113 | [ |
|
114 | 'data' => [ |
|
115 | 'image' => [ |
|
116 | 'url' => 'https://samples.clarifai.com/metro-north.jpg', |
|
117 | ] |
|
118 | ] |
|
119 | ] |
|
120 | ] |
|
121 | ); |
|
122 | ||
123 | $client = new Client($httpClient, 'client-id', 'client-secret'); |
|
124 | ||
125 | $response = $client->withAccessToken('access-token')->predict([ |
|
126 | 'https://samples.clarifai.com/metro-north.jpg', |
|
127 | ], Models::FOOD); |
|
128 | ||
129 | $this->assertTrue(is_array($response)); |
|
130 | $this->assertEquals([ |
|
131 | 'foo' => 'bar' |
|
132 | ], $response); |
|
133 | } |
|
134 | ||
135 | private function getHttpClientMock() |
|
136 | { |