Skip to content

Commit 78bed51

Browse files
committed
Fix offloading logic
1 parent b0749c8 commit 78bed51

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/Offload/Manager.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class Manager
3131
*/
3232
private ClientInterface $httpClient;
3333

34-
3534
/**
3635
* The manager options.
3736
*/

tests/Unit/Offload/ManagerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testDeleteImage()
6666
return $return;
6767
});
6868

69-
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->deleteImage('image_id');
69+
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->deleteImage('image_id');
7070
}
7171

7272
public function testDeleteImageWithBadResponseException()
@@ -97,7 +97,7 @@ public function testDeleteImageWithBadResponseException()
9797
return $return;
9898
});
9999

100-
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->deleteImage('image_id');
100+
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->deleteImage('image_id');
101101
}
102102

103103
public function testDeleteImageWithNonBadResponseException()
@@ -130,7 +130,7 @@ public function testDeleteImageWithNonBadResponseException()
130130
return $return;
131131
});
132132

133-
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->deleteImage('image_id');
133+
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->deleteImage('image_id');
134134
}
135135

136136
public function testGetImageUrl()
@@ -157,7 +157,7 @@ public function testGetImageUrl()
157157
return $return;
158158
});
159159

160-
$this->assertSame('https://cdn.optimole.com/image_id', (new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getImageUrl('image_id'));
160+
$this->assertSame('https://cdn.optimole.com/image_id', (new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getImageUrl('image_id'));
161161
}
162162

163163
public function testGetImageUrlReturnNullWithBadResponseException()
@@ -188,7 +188,7 @@ public function testGetImageUrlReturnNullWithBadResponseException()
188188
return $return;
189189
});
190190

191-
$this->assertNull((new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getImageUrl('image_id'));
191+
$this->assertNull((new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getImageUrl('image_id'));
192192
}
193193

194194
public function testGetImageUrlWithMissingGetUrlKey()
@@ -218,7 +218,7 @@ public function testGetImageUrlWithMissingGetUrlKey()
218218
return $return;
219219
});
220220

221-
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getImageUrl('image_id');
221+
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getImageUrl('image_id');
222222
}
223223

224224
public function testGetUsage()
@@ -229,7 +229,7 @@ public function testGetUsage()
229229
->with($this->identicalTo('POST'), $this->identicalTo('https://dashboard_api_url/optml/v2/account/details'), $this->identicalTo(null), $this->identicalTo(['Authorization' => 'Bearer optimole_key', 'Content-Type' => 'application/json']))
230230
->willReturn(['data' => ['offload_limit' => 5000, 'offloaded_images' => 42]]);
231231

232-
$usage = (new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getUsage();
232+
$usage = (new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getUsage();
233233

234234
$this->assertSame(42, $usage->getCurrent());
235235
$this->assertSame(5000, $usage->getLimit());
@@ -246,7 +246,7 @@ public function testGetUsageWithMissingOffloadedImages()
246246
->with($this->identicalTo('POST'), $this->identicalTo('https://dashboard_api_url/optml/v2/account/details'), $this->identicalTo(null), $this->identicalTo(['Authorization' => 'Bearer optimole_key', 'Content-Type' => 'application/json']))
247247
->willReturn(['data' => ['offload_limit' => 5000]]);
248248

249-
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getUsage();
249+
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getUsage();
250250
}
251251

252252
public function testGetUsageWithMissingOffloadLimit()
@@ -260,7 +260,7 @@ public function testGetUsageWithMissingOffloadLimit()
260260
->with($this->identicalTo('POST'), $this->identicalTo('https://dashboard_api_url/optml/v2/account/details'), $this->identicalTo(null), $this->identicalTo(['Authorization' => 'Bearer optimole_key', 'Content-Type' => 'application/json']))
261261
->willReturn(['data' => ['offloaded_images' => 42]]);
262262

263-
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getUsage();
263+
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->getUsage();
264264
}
265265

266266
public function testUpdateImageMetadata()
@@ -275,7 +275,7 @@ public function testUpdateImageMetadata()
275275
['data' => ['cdn_key' => 'cdn_key', 'cdn_secret' => 'cdn_secret']],
276276
],
277277
[
278-
['POST', 'https://upload_api_url', ['userKey' => 'cdn_key', 'secret' => 'cdn_secret', 'id' => 'image_id', 'originalFileSize' => 42, 'height' => 100, 'width' => 200, 'originalUrl'=>'originurl', 'updateDynamo' => 'success'], ['Content-Type' => 'application/json']],
278+
['POST', 'https://upload_api_url', ['userKey' => 'cdn_key', 'secret' => 'cdn_secret', 'id' => 'image_id', 'originalFileSize' => 42, 'height' => 100, 'width' => 200, 'originalUrl' => 'originurl', 'updateDynamo' => 'success'], ['Content-Type' => 'application/json']],
279279
['success'],
280280
],
281281
];
@@ -287,7 +287,7 @@ public function testUpdateImageMetadata()
287287
return $return;
288288
});
289289

290-
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key'=>'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->updateImageMetadata('image_id', 42, 100, 200,'originurl');
290+
(new Manager($httpClient, ['dashboard_api_url' => 'https://dashboard_api_url', 'dashboard_api_key' => 'optimole_key', 'upload_api_url' => 'https://upload_api_url']))->updateImageMetadata('image_id', 42, 100, 200, 'originurl');
291291
}
292292

293293
public function testUpdateImageMetadataWithInvalidImageHeight()

0 commit comments

Comments
 (0)