From f60c2bf32c37b41d52e05fe5d18b5ff00bdbe6aa Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Mon, 13 Apr 2020 23:49:23 +0200 Subject: [PATCH] Use stricter assertion in tests --- .../Tests/ChangelogConfigTest.php | 32 +++++++++---------- .../Tests/IssueClientResponseTest.php | 4 +-- .../Tests/IssueClientTest.php | 8 ++--- .../Tests/IssueFactoryTest.php | 12 +++---- .../Tests/IssueFetcherTest.php | 2 +- .../Tests/IssueGroupTest.php | 4 +-- tests/ChangelogGenerator/Tests/IssueTest.php | 16 +++++----- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/ChangelogGenerator/Tests/ChangelogConfigTest.php b/tests/ChangelogGenerator/Tests/ChangelogConfigTest.php index bbc7fc0..60becd0 100644 --- a/tests/ChangelogGenerator/Tests/ChangelogConfigTest.php +++ b/tests/ChangelogGenerator/Tests/ChangelogConfigTest.php @@ -34,43 +34,43 @@ final class ChangelogConfigTest extends TestCase public function testGetSetUser() : void { - self::assertEquals($this->user, $this->changelogConfig->getUser()); + self::assertSame($this->user, $this->changelogConfig->getUser()); $this->changelogConfig->setUser('romanb'); - self::assertEquals('romanb', $this->changelogConfig->getUser()); + self::assertSame('romanb', $this->changelogConfig->getUser()); } public function testGetSetRepository() : void { - self::assertEquals($this->repository, $this->changelogConfig->getRepository()); + self::assertSame($this->repository, $this->changelogConfig->getRepository()); $this->changelogConfig->setRepository('purl'); - self::assertEquals('purl', $this->changelogConfig->getRepository()); + self::assertSame('purl', $this->changelogConfig->getRepository()); } public function testGetSetMilestone() : void { - self::assertEquals($this->milestone, $this->changelogConfig->getMilestone()); + self::assertSame($this->milestone, $this->changelogConfig->getMilestone()); $this->changelogConfig->setMilestone('1.0'); - self::assertEquals('1.0', $this->changelogConfig->getMilestone()); + self::assertSame('1.0', $this->changelogConfig->getMilestone()); } public function testGetSetLabels() : void { - self::assertEquals($this->labels, $this->changelogConfig->getLabels()); + self::assertSame($this->labels, $this->changelogConfig->getLabels()); $this->changelogConfig->setLabels(['Improvement']); - self::assertEquals(['Improvement'], $this->changelogConfig->getLabels()); + self::assertSame(['Improvement'], $this->changelogConfig->getLabels()); } public function testGetSetIncludeOpen() : void { - self::assertEquals($this->includeOpen, $this->changelogConfig->shouldIncludeOpen()); + self::assertSame($this->includeOpen, $this->changelogConfig->shouldIncludeOpen()); $this->changelogConfig->setIncludeOpen(true); @@ -79,11 +79,11 @@ public function testGetSetIncludeOpen() : void public function testGetSetOptions() : void { - self::assertEquals(['rootGitHubUrl' => 'https://api.github.com'], $this->changelogConfig->getOptions()); + self::assertSame(['rootGitHubUrl' => 'https://api.github.com'], $this->changelogConfig->getOptions()); $this->changelogConfig->setOptions(['rootGitHubUrl' => 'https://git.mycompany.com/api/v3']); - self::assertEquals(['rootGitHubUrl' => 'https://git.mycompany.com/api/v3'], $this->changelogConfig->getOptions()); + self::assertSame(['rootGitHubUrl' => 'https://git.mycompany.com/api/v3'], $this->changelogConfig->getOptions()); } public function testGetSetOption() : void @@ -97,33 +97,33 @@ public function testGetSetOption() : void public function testGetMilestoneIssuesUrl() : void { - self::assertEquals('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); + self::assertSame('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); } public function testGetMilestoneIssuesUrlNoLabel() : void { - self::assertEquals('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed', $this->changelogConfig->getMilestoneIssuesUrl('')); + self::assertSame('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed', $this->changelogConfig->getMilestoneIssuesUrl('')); } public function testGetMilestoneIssuesUrlWithCustomRootGitHubUrl() : void { $this->changelogConfig->setOptions(['rootGitHubUrl' => 'https://git.mycompany.com/api/v3']); - self::assertEquals('https://git.mycompany.com/api/v3/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); + self::assertSame('https://git.mycompany.com/api/v3/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); } public function testGetMilestoneIssuesUrlWithMissingRootGitHubUrl() : void { $this->changelogConfig->setOptions([]); - self::assertEquals('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); + self::assertSame('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); } public function testGetMilestoneIssuesUrlWithOpenIncluded() : void { $this->changelogConfig->setIncludeOpen(true); - self::assertEquals('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); + self::assertSame('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+label%3AEnhancement', $this->changelogConfig->getMilestoneIssuesUrl('Enhancement')); } public function testIsValid() : void diff --git a/tests/ChangelogGenerator/Tests/IssueClientResponseTest.php b/tests/ChangelogGenerator/Tests/IssueClientResponseTest.php index 5ae3909..5ac50cd 100644 --- a/tests/ChangelogGenerator/Tests/IssueClientResponseTest.php +++ b/tests/ChangelogGenerator/Tests/IssueClientResponseTest.php @@ -20,12 +20,12 @@ final class IssueClientResponseTest extends TestCase public function testGetBody() : void { - self::assertEquals($this->body, $this->issueClientResponse->getBody()); + self::assertSame($this->body, $this->issueClientResponse->getBody()); } public function testGetNextUrl() : void { - self::assertEquals($this->nextUrl, $this->issueClientResponse->getNextUrl()); + self::assertSame($this->nextUrl, $this->issueClientResponse->getNextUrl()); } protected function setUp() : void diff --git a/tests/ChangelogGenerator/Tests/IssueClientTest.php b/tests/ChangelogGenerator/Tests/IssueClientTest.php index a9c7490..2c2dbb5 100644 --- a/tests/ChangelogGenerator/Tests/IssueClientTest.php +++ b/tests/ChangelogGenerator/Tests/IssueClientTest.php @@ -67,8 +67,8 @@ public function testExecute() : void $response = $this->issueClient->execute('https://www.google.com'); - self::assertEquals(['test' => true], $response->getBody()); - self::assertEquals('https://www.google.com?next', $response->getNextUrl()); + self::assertSame(['test' => true], $response->getBody()); + self::assertSame('https://www.google.com?next', $response->getNextUrl()); } public function testExecuteNullNextUrl() : void @@ -112,7 +112,7 @@ public function testExecuteNullNextUrl() : void $response = $this->issueClient->execute('https://www.google.com'); - self::assertEquals(['test' => true], $response->getBody()); + self::assertSame(['test' => true], $response->getBody()); self::assertNull($response->getNextUrl()); } @@ -205,7 +205,7 @@ public function testExecuteWithGitHubCredentials() : void new GitHubUsernamePassword('username', 'password') ); - self::assertEquals(['test' => true], $response->getBody()); + self::assertSame(['test' => true], $response->getBody()); } protected function setUp() : void diff --git a/tests/ChangelogGenerator/Tests/IssueFactoryTest.php b/tests/ChangelogGenerator/Tests/IssueFactoryTest.php index 5b9d603..840dbfb 100644 --- a/tests/ChangelogGenerator/Tests/IssueFactoryTest.php +++ b/tests/ChangelogGenerator/Tests/IssueFactoryTest.php @@ -23,12 +23,12 @@ public function testCreate() : void 'labels' => [['name' => 'Enhancement']], ]); - self::assertEquals(1, $issue->getNumber()); - self::assertEquals('[Test] _ Title', $issue->getTitle()); - self::assertEquals('Test Body', $issue->getBody()); - self::assertEquals('https://google.com', $issue->getUrl()); - self::assertEquals('jwage', $issue->getUser()); - self::assertEquals(['Enhancement'], $issue->getLabels()); + self::assertSame(1, $issue->getNumber()); + self::assertSame('[Test] _ Title', $issue->getTitle()); + self::assertSame('Test Body', $issue->getBody()); + self::assertSame('https://google.com', $issue->getUrl()); + self::assertSame('jwage', $issue->getUser()); + self::assertSame(['Enhancement'], $issue->getLabels()); } protected function setUp() : void diff --git a/tests/ChangelogGenerator/Tests/IssueFetcherTest.php b/tests/ChangelogGenerator/Tests/IssueFetcherTest.php index 9198cea..10d2729 100644 --- a/tests/ChangelogGenerator/Tests/IssueFetcherTest.php +++ b/tests/ChangelogGenerator/Tests/IssueFetcherTest.php @@ -38,7 +38,7 @@ public function testFetchMilestoneIssues() : void $issues = $this->issueFetcher->fetchMilestoneIssues($changelogConfig); - self::assertEquals([1, 2], $issues); + self::assertSame([1, 2], $issues); } protected function setUp() : void diff --git a/tests/ChangelogGenerator/Tests/IssueGroupTest.php b/tests/ChangelogGenerator/Tests/IssueGroupTest.php index 3dc584e..fe3185d 100644 --- a/tests/ChangelogGenerator/Tests/IssueGroupTest.php +++ b/tests/ChangelogGenerator/Tests/IssueGroupTest.php @@ -22,12 +22,12 @@ final class IssueGroupTest extends TestCase public function testGetName() : void { - self::assertEquals($this->name, $this->issueGroup->getName()); + self::assertSame($this->name, $this->issueGroup->getName()); } public function testGetIssues() : void { - self::assertEquals($this->issues, $this->issueGroup->getIssues()); + self::assertSame($this->issues, $this->issueGroup->getIssues()); } public function testAddIssue() : void diff --git a/tests/ChangelogGenerator/Tests/IssueTest.php b/tests/ChangelogGenerator/Tests/IssueTest.php index 47d2c25..8b45701 100644 --- a/tests/ChangelogGenerator/Tests/IssueTest.php +++ b/tests/ChangelogGenerator/Tests/IssueTest.php @@ -14,32 +14,32 @@ final class IssueTest extends TestCase public function testNumber() : void { - self::assertEquals(1, $this->issue->getNumber()); + self::assertSame(1, $this->issue->getNumber()); } public function testGetTitle() : void { - self::assertEquals('Test Title', $this->issue->getTitle()); + self::assertSame('Test Title', $this->issue->getTitle()); } public function testGetBody() : void { - self::assertEquals('Test Body', $this->issue->getBody()); + self::assertSame('Test Body', $this->issue->getBody()); } public function testGetUrl() : void { - self::assertEquals('https://www.google.com', $this->issue->getUrl()); + self::assertSame('https://www.google.com', $this->issue->getUrl()); } public function testGetUser() : void { - self::assertEquals('jwage', $this->issue->getUser()); + self::assertSame('jwage', $this->issue->getUser()); } public function testGetLabels() : void { - self::assertEquals(['Enhancement'], $this->issue->getLabels()); + self::assertSame(['Enhancement'], $this->issue->getLabels()); } public function testIsPullRequest() : void @@ -93,7 +93,7 @@ public function testLinkedIssue() : void public function testRender() : void { - self::assertEquals(' - [1: Test Title](https://www.google.com) thanks to @jwage', $this->issue->render()); + self::assertSame(' - [1: Test Title](https://www.google.com) thanks to @jwage', $this->issue->render()); } public function testRenderMultiContributor() : void @@ -110,7 +110,7 @@ public function testRenderMultiContributor() : void $pullRequest->setLinkedIssue($this->issue); - self::assertEquals(' - [2: Test Title](https://www.google.com) thanks to @Ocramius and @jwage', $pullRequest->render()); + self::assertSame(' - [2: Test Title](https://www.google.com) thanks to @Ocramius and @jwage', $pullRequest->render()); } public function testEmptyBodyIssuesGetsRendered() : void