Merge pull request #9440 from samsonasik/refactor-assert-not
Some checks failed
AutoReview / Automatic Code Review (push) Has been cancelled
AutoReview / Check normalized composer.json (push) Has been cancelled
Coding Standards / PHP 8.1 Lint with PHP CS Fixer (push) Has been cancelled
Coding Standards / PHP 8.4 Lint with PHP CS Fixer (push) Has been cancelled
Check File Permissions / Check File Permission (push) Has been cancelled
PHPStan / PHP ${{ matrix.php-versions }} Static Analysis (push) Has been cancelled
PHPUnit / Setup PHP Version for Code Coverage (push) Has been cancelled
Psalm / Psalm Analysis (push) Has been cancelled
Rector / PHP 8.1 Analyze code (Rector) (push) Has been cancelled
Rector / PHP 8.4 Analyze code (Rector) (push) Has been cancelled
PHPUnit / Others (8.1) (push) Has been cancelled
PHPUnit / Others (8.2) (push) Has been cancelled
PHPUnit / Others (8.3) (push) Has been cancelled
PHPUnit / Others (8.4) (push) Has been cancelled
PHPUnit / DatabaseLive (MySQLi, 5.7, 8.1) (push) Has been cancelled
PHPUnit / DatabaseLive (MySQLi, 8.0, 8.1) (push) Has been cancelled
PHPUnit / DatabaseLive (MySQLi, 8.0, 8.2) (push) Has been cancelled
PHPUnit / DatabaseLive (MySQLi, 8.0, 8.3) (push) Has been cancelled
PHPUnit / DatabaseLive (MySQLi, 8.0, 8.4) (push) Has been cancelled
PHPUnit / DatabaseLive (OCI8, 8.0, 8.1) (push) Has been cancelled
PHPUnit / DatabaseLive (OCI8, 8.0, 8.2) (push) Has been cancelled
PHPUnit / DatabaseLive (OCI8, 8.0, 8.3) (push) Has been cancelled
PHPUnit / DatabaseLive (OCI8, 8.0, 8.4) (push) Has been cancelled
PHPUnit / DatabaseLive (Postgre, 8.0, 8.1) (push) Has been cancelled
PHPUnit / DatabaseLive (Postgre, 8.0, 8.2) (push) Has been cancelled
PHPUnit / DatabaseLive (Postgre, 8.0, 8.3) (push) Has been cancelled
PHPUnit / DatabaseLive (Postgre, 8.0, 8.4) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLSRV, 8.0, 8.1) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLSRV, 8.0, 8.2) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLSRV, 8.0, 8.3) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLSRV, 8.0, 8.4) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLite3, 8.0, 8.1) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLite3, 8.0, 8.2) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLite3, 8.0, 8.3) (push) Has been cancelled
PHPUnit / DatabaseLive (SQLite3, 8.0, 8.4) (push) Has been cancelled
PHPUnit / SeparateProcess (8.1) (push) Has been cancelled
PHPUnit / SeparateProcess (8.2) (push) Has been cancelled
PHPUnit / SeparateProcess (8.3) (push) Has been cancelled
PHPUnit / SeparateProcess (8.4) (push) Has been cancelled
PHPUnit / CacheLive (8.1) (push) Has been cancelled
PHPUnit / CacheLive (8.2) (push) Has been cancelled
PHPUnit / CacheLive (8.3) (push) Has been cancelled
PHPUnit / CacheLive (8.4) (push) Has been cancelled
PHPUnit / Upload coverage results to Coveralls (push) Has been cancelled

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 10:02:36 +07:00 committed by GitHub
commit e89ef62f33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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