Skip to content

Commit e89ef62

Browse files
authoredFeb 4, 2025··
Merge pull request #9440 from samsonasik/refactor-assert-not
refactor: use assertNotInstanceOf over assertNull on nullable object return and flip actual/expect on constant check
2 parents 74a7861 + 3eae990 commit e89ef62

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed
 

‎tests/system/Cache/ResponseCacheTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function testCachePageIncomingRequest(): void
128128

129129
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
130130

131-
$this->assertNull($cachedResponse);
131+
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
132132
}
133133

134134
public function testCachePageIncomingRequestWithCacheQueryString(): void
@@ -159,14 +159,14 @@ public function testCachePageIncomingRequestWithCacheQueryString(): void
159159
$request = $this->createIncomingRequest('foo/bar', ['xfoo' => 'bar', 'bar' => 'baz']);
160160
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
161161

162-
$this->assertNull($cachedResponse);
162+
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
163163

164164
// Check cache with another request with the different URI path.
165165
$request = $this->createIncomingRequest('another');
166166

167167
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
168168

169-
$this->assertNull($cachedResponse);
169+
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
170170
}
171171

172172
public function testCachePageIncomingRequestWithHttpMethods(): void
@@ -186,7 +186,7 @@ public function testCachePageIncomingRequestWithHttpMethods(): void
186186
$request = $this->createIncomingRequest('foo/bar')->withMethod('POST');
187187
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
188188

189-
$this->assertNull($cachedResponse);
189+
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
190190
}
191191

192192
public function testCachePageCLIRequest(): void
@@ -214,7 +214,7 @@ public function testCachePageCLIRequest(): void
214214

215215
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
216216

217-
$this->assertNull($cachedResponse);
217+
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
218218
}
219219

220220
public function testUnserializeError(): void

‎tests/system/Filters/CorsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testBeforeDoesNothingWhenCliRequest(): void
102102

103103
$return = $this->cors->before($cliRequest);
104104

105-
$this->assertNull($return);
105+
$this->assertNotInstanceOf(ResponseInterface::class, $return);
106106
}
107107

108108
private function assertHeader(string $name, string $value): void

‎tests/system/HTTP/Files/FileCollectionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public function testFileNoExistSingleFile(): void
524524

525525
$collection = new FileCollection();
526526
$file = $collection->getFile('fileuser');
527-
$this->assertNull($file);
527+
$this->assertNotInstanceOf(UploadedFile::class, $file);
528528
}
529529

530530
public function testFileReturnValidMultipleFiles(): void
@@ -686,7 +686,7 @@ public function testDoesntHaveFile(): void
686686
$collection = new FileCollection();
687687

688688
$this->assertFalse($collection->hasFile('my-form.detailz.avatars.0'));
689-
$this->assertNull($collection->getFile('my-form.detailz.avatars.0'));
689+
$this->assertNotInstanceOf(UploadedFile::class, $collection->getFile('my-form.detailz.avatars.0'));
690690
}
691691

692692
public function testGetFileMultipleHasNoFile(): void

‎tests/system/HTTP/ResponseTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public function testVagueDownload(): void
495495

496496
$actual = $response->download();
497497

498-
$this->assertNull($actual);
498+
$this->assertNotInstanceOf(DownloadResponse::class, $actual);
499499
}
500500

501501
public function testPretendMode(): void

‎tests/system/Images/GDHandlerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public function testImageConvert(): void
411411
$this->handler->withFile($this->origin . 'ci-logo.jpeg');
412412
$this->handler->convert(IMAGETYPE_PNG);
413413
$this->handler->save($this->start . 'work/ci-logo.png');
414-
$this->assertSame(exif_imagetype($this->start . 'work/ci-logo.png'), IMAGETYPE_PNG);
414+
$this->assertSame(IMAGETYPE_PNG, exif_imagetype($this->start . 'work/ci-logo.png'));
415415
}
416416

417417
public function testImageConvertPngToWebp(): void
@@ -420,7 +420,7 @@ public function testImageConvertPngToWebp(): void
420420
$this->handler->convert(IMAGETYPE_WEBP);
421421
$saved = $this->start . 'work/rocket.webp';
422422
$this->handler->save($saved);
423-
$this->assertSame(exif_imagetype($saved), IMAGETYPE_WEBP);
423+
$this->assertSame(IMAGETYPE_WEBP, exif_imagetype($saved));
424424
}
425425

426426
public function testImageReorientLandscape(): void

‎tests/system/Images/ImageMagickHandlerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public function testImageConvert(): void
447447
$this->handler->withFile($this->origin . 'ci-logo.jpeg');
448448
$this->handler->convert(IMAGETYPE_PNG);
449449
$this->handler->save($this->root . 'ci-logo.png');
450-
$this->assertSame(exif_imagetype($this->root . 'ci-logo.png'), IMAGETYPE_PNG);
450+
$this->assertSame(IMAGETYPE_PNG, exif_imagetype($this->root . 'ci-logo.png'));
451451
}
452452

453453
public function testImageReorientLandscape(): void

0 commit comments

Comments
 (0)
Please sign in to comment.