Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/system/Cache/ResponseCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testCachePageIncomingRequest(): void

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

$this->assertNull($cachedResponse);
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
}

public function testCachePageIncomingRequestWithCacheQueryString(): void
Expand Down Expand Up @@ -159,14 +159,14 @@ public function testCachePageIncomingRequestWithCacheQueryString(): void
$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
Expand All @@ -186,7 +186,7 @@ public function testCachePageIncomingRequestWithHttpMethods(): void
$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
Expand Down Expand Up @@ -214,7 +214,7 @@ public function testCachePageCLIRequest(): void

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

$this->assertNull($cachedResponse);
$this->assertNotInstanceOf(ResponseInterface::class, $cachedResponse);
}

public function testUnserializeError(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Filters/CorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function testBeforeDoesNothingWhenCliRequest(): void

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

$this->assertNull($return);
$this->assertNotInstanceOf(ResponseInterface::class, $return);
}

private function assertHeader(string $name, string $value): void
Expand Down
4 changes: 2 additions & 2 deletions tests/system/HTTP/Files/FileCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public function testFileNoExistSingleFile(): void

$collection = new FileCollection();
$file = $collection->getFile('fileuser');
$this->assertNull($file);
$this->assertNotInstanceOf(UploadedFile::class, $file);
}

public function testFileReturnValidMultipleFiles(): void
Expand Down Expand Up @@ -686,7 +686,7 @@ public function testDoesntHaveFile(): void
$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
Expand Down
2 changes: 1 addition & 1 deletion tests/system/HTTP/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public function testVagueDownload(): void

$actual = $response->download();

$this->assertNull($actual);
$this->assertNotInstanceOf(DownloadResponse::class, $actual);
}

public function testPretendMode(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Images/GDHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public function testImageConvert(): void
$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
Expand All @@ -420,7 +420,7 @@ public function testImageConvertPngToWebp(): void
$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
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Images/ImageMagickHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,10 @@
$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

Check warning on line 453 in tests/system/Images/ImageMagickHandlerTest.php

View workflow job for this annotation

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.6271s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientLandscape
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg';
Expand All @@ -469,7 +469,7 @@
}
}

public function testImageReorientPortrait(): void

Check warning on line 472 in tests/system/Images/ImageMagickHandlerTest.php

View workflow job for this annotation

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.5492s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientPortrait
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg';
Expand Down
Loading