Skip to content

Commit

Permalink
Use stricter assertion in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel committed May 25, 2020
1 parent ee553c6 commit f60c2bf
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
32 changes: 16 additions & 16 deletions tests/ChangelogGenerator/Tests/ChangelogConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/ChangelogGenerator/Tests/IssueClientResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/ChangelogGenerator/Tests/IssueClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/ChangelogGenerator/Tests/IssueFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/ChangelogGenerator/Tests/IssueFetcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/ChangelogGenerator/Tests/IssueGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions tests/ChangelogGenerator/Tests/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f60c2bf

Please sign in to comment.