Skip to content

Commit

Permalink
Improve PHPUnit assertions (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k authored Mar 8, 2021
1 parent 3cc224e commit 507a4bb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions tests/Functional/Command/ProxySyncReleasesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testSyncReleases(): void
$commandTester = new CommandTester($command);
$result = $commandTester->execute([]);

self::assertTrue(file_exists($newDist));
self::assertFileExists($newDist);
self::assertEquals($result, 0);
@unlink($newDist);

Expand All @@ -44,7 +44,7 @@ public function testSyncReleases(): void
$commandTester = new CommandTester($command);
$result = $commandTester->execute([]);

self::assertFalse(file_exists($newDist));
self::assertFileDoesNotExist($newDist);
self::assertEquals($result, 0);
}

Expand All @@ -68,7 +68,7 @@ public function testJobLocking(): void
$commandTester = new CommandTester($command);
$result = $commandTester->execute([]);

self::assertFalse(file_exists($newDist));
self::assertFileDoesNotExist($newDist);
self::assertEquals($result, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testOrganizationsList(): void
self::assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());

$json = $this->jsonResponse();
self::assertEquals(count($json['data']), 1);
self::assertCount(1, $json['data']);
self::assertEquals($json['data'][0]['name'], 'Buddy works');
self::assertEquals($json['data'][0]['alias'], 'buddy-works');
self::assertEquals($json['data'][0]['hasAnonymousAccess'], false);
Expand All @@ -56,7 +56,7 @@ public function testOrganizationsListPagination(): void

$json = $this->jsonResponse();

self::assertEquals(count($json['data']), 20);
self::assertCount(20, $json['data']);
self::assertEquals($json['data'][0]['name'], 'test-list-name#27');
self::assertEquals($json['data'][19]['name'], 'test-list-name#7');

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Controller/Api/PackageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function testPackagesListPagination(): void

$json = $this->jsonResponse();

self::assertEquals(count($json['data']), 20);
self::assertCount(20, $json['data']);
self::assertEquals($json['total'], 41);

$baseUrl = $this->urlTo('api_packages', ['organization' => self::$organization], UrlGeneratorInterface::ABSOLUTE_URL);
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Controller/Api/TokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testTokensList(): void
self::assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());

$json = $this->jsonResponse();
self::assertEquals(count($json['data']), 1);
self::assertCount(1, $json['data']);
self::assertEquals($json['data'][0]['name'], 'test-list-name');
self::assertEquals($json['data'][0]['value'], 'test-list-value');
self::assertNotEmpty($json['data'][0]['createdAt']);
Expand All @@ -62,7 +62,7 @@ public function testTokensListPagination(): void

$json = $this->jsonResponse();

self::assertEquals(count($json['data']), 20);
self::assertCount(20, $json['data']);
self::assertEquals($json['data'][0]['name'], 'test-list-name#28');
self::assertEquals($json['data'][19]['name'], 'test-list-name#8');

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Service/Downloader/ReactDownloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testSuccessDownload(): void
{
$packages = __DIR__.'/../../../Resources/packages.json';

self::assertTrue(is_resource((new ReactDownloader())->getContents($packages)->getOrNull()));
self::assertIsResource((new ReactDownloader())->getContents($packages)->getOrNull());
}

public function testFailedDownload(): void
Expand Down

0 comments on commit 507a4bb

Please sign in to comment.