|
269 | 269 | Event::assertDispatched(FlysystemCloudinaryResponseLog::class, 4); |
270 | 270 | }); |
271 | 271 |
|
272 | | -it('can get url', function () { |
| 272 | +it('can get url via request', function () { |
273 | 273 | Http::fake(); |
274 | 274 | $mock = $this->mock(Cloudinary::class, function (MockInterface $mock) { |
275 | 275 | $mock->shouldReceive('uploadApi->explicit')->once()->andReturn(new ApiResponse([ |
|
279 | 279 | }); |
280 | 280 | $adapter = new FlysystemCloudinaryAdapter($mock); |
281 | 281 |
|
282 | | - $url = $adapter->getUrl('::path::'); |
| 282 | + $url = $adapter->getUrlViaRequest('::path::'); |
283 | 283 |
|
284 | 284 | $this->assertSame('::secure-url::', $url); |
285 | 285 | Event::assertDispatched(FlysystemCloudinaryResponseLog::class, 2); |
286 | 286 | }); |
| 287 | + |
| 288 | +it('can get url', function () { |
| 289 | + // Secure URL |
| 290 | + |
| 291 | + $cloudinary = new Cloudinary([ |
| 292 | + 'cloud_name' => env('CLOUDINARY_CLOUD_NAME'), |
| 293 | + 'api_key' => env('CLOUDINARY_API_KEY'), |
| 294 | + 'api_secret' => env('CLOUDINARY_API_SECRET'), |
| 295 | + 'url' => [ |
| 296 | + 'secure' => true, |
| 297 | + ], |
| 298 | + ]); |
| 299 | + |
| 300 | + $adapter = new FlysystemCloudinaryAdapter($cloudinary); |
| 301 | + |
| 302 | + $url = $adapter->getUrl('::path::'); |
| 303 | + |
| 304 | + expect($url) |
| 305 | + ->toContain('https://', '::path::') |
| 306 | + ->not->toContain('http://'); |
| 307 | + |
| 308 | + // Unsecure URL |
| 309 | + |
| 310 | + $cloudinary = new Cloudinary([ |
| 311 | + 'cloud_name' => env('CLOUDINARY_CLOUD_NAME'), |
| 312 | + 'api_key' => env('CLOUDINARY_API_KEY'), |
| 313 | + 'api_secret' => env('CLOUDINARY_API_SECRET'), |
| 314 | + 'url' => [ |
| 315 | + 'secure' => false, |
| 316 | + ], |
| 317 | + ]); |
| 318 | + |
| 319 | + $adapter = new FlysystemCloudinaryAdapter($cloudinary); |
| 320 | + |
| 321 | + $url = $adapter->getUrl('::path::'); |
| 322 | + |
| 323 | + expect($url)->toContain('http://', '::path::') |
| 324 | + ->not->toContain('https://'); |
| 325 | +}); |
| 326 | + |
| 327 | +it('can get url with option', function () { |
| 328 | + // Secure URL |
| 329 | + |
| 330 | + $cloudinary = new Cloudinary([ |
| 331 | + 'cloud_name' => env('CLOUDINARY_CLOUD_NAME'), |
| 332 | + 'api_key' => env('CLOUDINARY_API_KEY'), |
| 333 | + 'api_secret' => env('CLOUDINARY_API_SECRET'), |
| 334 | + 'url' => [ |
| 335 | + 'secure' => true, |
| 336 | + ], |
| 337 | + ]); |
| 338 | + |
| 339 | + $adapter = new FlysystemCloudinaryAdapter($cloudinary); |
| 340 | + |
| 341 | + $url = $adapter->getUrl([ |
| 342 | + 'path' => '::path::', |
| 343 | + 'options' => [ |
| 344 | + 'w_64', |
| 345 | + 'h_64', |
| 346 | + 'c_fill', |
| 347 | + 'auto', |
| 348 | + ], |
| 349 | + ]); |
| 350 | + |
| 351 | + expect($url) |
| 352 | + ->toContain('https://', '::path::') |
| 353 | + ->toContain('w_64', 'h_64', 'c_fill', 'auto') |
| 354 | + ->not->toContain('http://'); |
| 355 | +}); |
0 commit comments