refactor: use assertNotInstanceOf over assertNull on nullable object return and flip actual/expect on constant check

This commit is contained in:
Abdul Malik Ikhsan 2025-02-04 09:00:10 +07:00
parent 74a78610fd
commit 3eae99070b
No known key found for this signature in database
GPG Key ID: 69AC5BC354C89BE6
6 changed files with 12 additions and 12 deletions

View File

@ -128,7 +128,7 @@ final class ResponseCacheTest extends CIUnitTestCase
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
$this->assertNull($cachedResponse);
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
}
public function testCachePageIncomingRequestWithCacheQueryString(): void
@ -159,14 +159,14 @@ final class ResponseCacheTest extends CIUnitTestCase
$request = $this->createIncomingRequest('foo/bar', ['xfoo' => 'bar', 'bar' => 'baz']);
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
$this->assertNull($cachedResponse);
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
// Check cache with another request with the different URI path.
$request = $this->createIncomingRequest('another');
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
$this->assertNull($cachedResponse);
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
}
public function testCachePageIncomingRequestWithHttpMethods(): void
@ -186,7 +186,7 @@ final class ResponseCacheTest extends CIUnitTestCase
$request = $this->createIncomingRequest('foo/bar')->withMethod('POST');
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
$this->assertNull($cachedResponse);
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
}
public function testCachePageCLIRequest(): void
@ -214,7 +214,7 @@ final class ResponseCacheTest extends CIUnitTestCase
$cachedResponse = $pageCache->get($request, new Response($this->appConfig));
$this->assertNull($cachedResponse);
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
}
public function testUnserializeError(): void

View File

@ -102,7 +102,7 @@ final class CorsTest extends CIUnitTestCase
$return = $this->cors->before($cliRequest);
$this->assertNull($return);
$this->assertNotInstanceOf(ResponseInterface::class, $return);
}
private function assertHeader(string $name, string $value): void

View File

@ -524,7 +524,7 @@ final class FileCollectionTest extends CIUnitTestCase
$collection = new FileCollection();
$file = $collection->getFile('fileuser');
$this->assertNull($file);
$this->assertNotInstanceOf(UploadedFile::class, $file);
}
public function testFileReturnValidMultipleFiles(): void
@ -686,7 +686,7 @@ final class FileCollectionTest extends CIUnitTestCase
$collection = new FileCollection();
$this->assertFalse($collection->hasFile('my-form.detailz.avatars.0'));
$this->assertNull($collection->getFile('my-form.detailz.avatars.0'));
$this->assertNotInstanceOf(UploadedFile::class, $collection->getFile('my-form.detailz.avatars.0'));
}
public function testGetFileMultipleHasNoFile(): void

View File

@ -495,7 +495,7 @@ final class ResponseTest extends CIUnitTestCase
$actual = $response->download();
$this->assertNull($actual);
$this->assertNotInstanceOf(DownloadResponse::class, $actual);
}
public function testPretendMode(): void

View File

@ -411,7 +411,7 @@ final class GDHandlerTest extends CIUnitTestCase
$this->handler->withFile($this->origin . 'ci-logo.jpeg');
$this->handler->convert(IMAGETYPE_PNG);
$this->handler->save($this->start . 'work/ci-logo.png');
$this->assertSame(exif_imagetype($this->start . 'work/ci-logo.png'), IMAGETYPE_PNG);
$this->assertSame(IMAGETYPE_PNG, exif_imagetype($this->start . 'work/ci-logo.png'));
}
public function testImageConvertPngToWebp(): void
@ -420,7 +420,7 @@ final class GDHandlerTest extends CIUnitTestCase
$this->handler->convert(IMAGETYPE_WEBP);
$saved = $this->start . 'work/rocket.webp';
$this->handler->save($saved);
$this->assertSame(exif_imagetype($saved), IMAGETYPE_WEBP);
$this->assertSame(IMAGETYPE_WEBP, exif_imagetype($saved));
}
public function testImageReorientLandscape(): void

View File

@ -447,7 +447,7 @@ final class ImageMagickHandlerTest extends CIUnitTestCase
$this->handler->withFile($this->origin . 'ci-logo.jpeg');
$this->handler->convert(IMAGETYPE_PNG);
$this->handler->save($this->root . 'ci-logo.png');
$this->assertSame(exif_imagetype($this->root . 'ci-logo.png'), IMAGETYPE_PNG);
$this->assertSame(IMAGETYPE_PNG, exif_imagetype($this->root . 'ci-logo.png'));
}
public function testImageReorientLandscape(): void