Skip to content

Commit 97cc25e

Browse files
authored
Merge pull request #43 from msheheryar1/dev
test cases for method assert
2 parents b1b9731 + 55bf3f4 commit 97cc25e

File tree

7 files changed

+171
-57
lines changed

7 files changed

+171
-57
lines changed

sample/file_management/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"fileType" => "all",
2929
"limit" => 10,
3030
"skip" => 0,
31-
"tags" => implode(",",["tag3","tag4"]),
31+
"tags" => ["tag3","tag4"],
3232
]);
3333

3434
echo "\n\n";

src/ImageKit/Manage/File.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,12 @@ public static function updateDetails($fileId, $updateData, GuzzleHttpWrapper $re
542542
{
543543
$obj = (object)$updateData;
544544

545-
if (isset($obj->tags) && is_string($obj->tags)) {
546-
$updateData['tags'] = explode(',', $obj->tags);
545+
if (isset($obj->tags) && ($obj->tags !== null) && ($obj->tags !== 'undefined') && !is_array($obj->tags)) {
546+
return Response::respond(true, ((object)ErrorMessages::$UPDATE_DATA_TAGS_INVALID));
547547
}
548548

549-
if (isset($obj->customCoordinates) && is_array($obj->customCoordinates)) {
550-
$updateData['customCoordinates'] = implode(',', $obj->customCoordinates);
549+
if (isset($obj->customCoordinates) && ($obj->customCoordinates !== 'undefined') && is_array($obj->customCoordinates)) {
550+
return Response::respond(true, ((object)ErrorMessages::$UPDATE_DATA_COORDS_INVALID));
551551
}
552552

553553
$resource->setDatas($updateData);

tests/ImageKit/Manage/CacheTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public function testPurgeCache()
5959

6060
// Response Check
6161
CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result));
62+
63+
// Assert Method
64+
$requestMethod = $container[0]['request']->getMethod();
65+
FileTest::assertEquals($requestMethod,'POST');
6266
}
6367

6468
/**
@@ -122,9 +126,12 @@ public function testPurgeCacheStatus()
122126
CacheTest::assertEquals("/v1/files/purge/{$cacheRequestId}",$requestPath);
123127
CacheTest::assertEmpty($stream);
124128

125-
126129
// Response Check
127130
CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result));
131+
132+
// Assert Method
133+
$requestMethod = $container[0]['request']->getMethod();
134+
FileTest::assertEquals($requestMethod,'GET');
128135
}
129136

130137
/**

tests/ImageKit/Manage/CustomMetadataTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public function testCreateFields()
7979

8080
// Response Check
8181
CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result));
82+
83+
// Assert Method
84+
$requestMethod = $container[0]['request']->getMethod();
85+
FileTest::assertEquals($requestMethod,'POST');
8286
}
8387

8488
/**
@@ -250,6 +254,10 @@ public function testGetFields()
250254

251255
// Response Check
252256
CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result));
257+
258+
// Assert Method
259+
$requestMethod = $container[0]['request']->getMethod();
260+
FileTest::assertEquals($requestMethod,'GET');
253261
}
254262

255263

@@ -310,6 +318,10 @@ public function testGetFieldsWithoutIncludeDeleted()
310318

311319
// Response Check
312320
CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result));
321+
322+
// Assert Method
323+
$requestMethod = $container[0]['request']->getMethod();
324+
FileTest::assertEquals($requestMethod,'GET');
313325
}
314326

315327
/**
@@ -376,6 +388,10 @@ public function testUpdateFields()
376388

377389
// Response Check
378390
CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result));
391+
392+
// Assert Method
393+
$requestMethod = $container[0]['request']->getMethod();
394+
FileTest::assertEquals($requestMethod,'PATCH');
379395
}
380396

381397
/**
@@ -548,6 +564,10 @@ public function testDeleteFields()
548564
// Response Check
549565
CacheTest::assertNull($response->result);
550566
CacheTest::assertNull($response->error);
567+
568+
// Assert Method
569+
$requestMethod = $container[0]['request']->getMethod();
570+
FileTest::assertEquals($requestMethod,'DELETE');
551571
}
552572

553573
/**

0 commit comments

Comments
 (0)