mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
refactor: use assertNotInstanceOf over assertNull on nullable object return and flip actual/expect on constant check
This commit is contained in:
parent
74a78610fd
commit
3eae99070b
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -495,7 +495,7 @@ final class ResponseTest extends CIUnitTestCase
|
||||
|
||||
$actual = $response->download();
|
||||
|
||||
$this->assertNull($actual);
|
||||
$this->assertNotInstanceOf(DownloadResponse::class, $actual);
|
||||
}
|
||||
|
||||
public function testPretendMode(): void
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user