diff --git a/composer.json b/composer.json index 936ea3b0..0f8a863f 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ ], "require-dev": { "friendsofphp/php-cs-fixer": "^3.95", - "phpunit/phpunit": "^11.5", + "phpunit/phpunit": "^13.4", "phpstan/phpstan": "^2.3", "phpstan/phpstan-phpunit": "^2", "phpstan/extension-installer": "^1.4.3", diff --git a/tests/Command/CiCommandTest.php b/tests/Command/CiCommandTest.php index ee1daa8c..4fbc133d 100644 --- a/tests/Command/CiCommandTest.php +++ b/tests/Command/CiCommandTest.php @@ -25,7 +25,7 @@ public function testValid(): void $platform = $this->createMock(Github::class); $platform->expects(static::once())->method('removePost'); - $detector = $this->createMock(PlatformDetector::class); + $detector = static::createStub(PlatformDetector::class); $detector->method('detect')->willReturn($platform); $output = new BufferedOutput(); @@ -39,10 +39,10 @@ public function testValid(): void public function testNotValid(): void { - $platform = $this->createMock(Github::class); + $platform = static::createStub(Github::class); $platform->method('post')->willReturn('https://danger.local/test'); - $detector = $this->createMock(PlatformDetector::class); + $detector = static::createStub(PlatformDetector::class); $detector->method('detect')->willReturn($platform); $output = new BufferedOutput(); @@ -55,10 +55,10 @@ public function testNotValid(): void public function testNotValidWarning(): void { - $platform = $this->createMock(Github::class); + $platform = static::createStub(Github::class); $platform->method('post')->willReturn('https://danger.local/test'); - $detector = $this->createMock(PlatformDetector::class); + $detector = static::createStub(PlatformDetector::class); $detector->method('detect')->willReturn($platform); $output = new BufferedOutput(); @@ -71,16 +71,16 @@ public function testNotValidWarning(): void public function testInvalidConfig(): void { - $platform = $this->createMock(Github::class); + $platform = static::createStub(Github::class); $platform->method('post')->willReturn('https://danger.local/test'); - $detector = $this->createMock(PlatformDetector::class); + $detector = static::createStub(PlatformDetector::class); $detector->method('detect')->willReturn($platform); $cmd = new CiCommand($detector, new ConfigLoader(), new Runner(), new HTMLRenderer()); static::expectException(\InvalidArgumentException::class); - static::expectExceptionMessage('Invalid config option given'); + static::expectExceptionMessageIsOrContains('Invalid config option given'); $input = new ArgvInput([]); $input->bind($cmd->getDefinition()); diff --git a/tests/Command/GithubCommandTest.php b/tests/Command/GithubCommandTest.php index daa0800f..058bcb69 100644 --- a/tests/Command/GithubCommandTest.php +++ b/tests/Command/GithubCommandTest.php @@ -22,10 +22,10 @@ class GithubCommandTest extends TestCase #[DataProvider('invalidUrls')] public function testInvalidUrl(string $url): void { - $cmd = new GithubCommand($this->createMock(Github::class), new ConfigLoader(), new Runner()); + $cmd = new GithubCommand(static::createStub(Github::class), new ConfigLoader(), new Runner()); static::expectException(\InvalidArgumentException::class); - static::expectExceptionMessage('The given url must be a valid Github URL'); + static::expectExceptionMessageIsOrContains('The given url must be a valid Github URL'); $cmd->run(new ArgvInput(['danger', $url]), new NullOutput()); } @@ -45,10 +45,10 @@ public static function invalidUrls(): array public function testInvalidConfig(): void { - $cmd = new GithubCommand($this->createMock(Github::class), new ConfigLoader(), new Runner()); + $cmd = new GithubCommand(static::createStub(Github::class), new ConfigLoader(), new Runner()); static::expectException(\InvalidArgumentException::class); - static::expectExceptionMessage('Invalid config option given'); + static::expectExceptionMessageIsOrContains('Invalid config option given'); $input = new ArgvInput(['danger', 'https://github.com']); $input->bind($cmd->getDefinition()); @@ -59,10 +59,10 @@ public function testInvalidConfig(): void public function testInvalidPr(): void { - $cmd = new GithubCommand($this->createMock(Github::class), new ConfigLoader(), new Runner()); + $cmd = new GithubCommand(static::createStub(Github::class), new ConfigLoader(), new Runner()); static::expectException(\InvalidArgumentException::class); - static::expectExceptionMessage('The PR links needs to be a string'); + static::expectExceptionMessageIsOrContains('The PR links needs to be a string'); $tester = new CommandTester($cmd); $tester->execute(['pr' => []]); diff --git a/tests/Command/GitlabCommandTest.php b/tests/Command/GitlabCommandTest.php index d2f6107d..1732cf60 100644 --- a/tests/Command/GitlabCommandTest.php +++ b/tests/Command/GitlabCommandTest.php @@ -25,7 +25,7 @@ public function testRunWithoutToken(): void unset($_SERVER['DANGER_GITLAB_TOKEN']); } - $cmd = new GitlabCommand($this->createMock(Gitlab::class), new ConfigLoader(), new Runner()); + $cmd = new GitlabCommand(static::createStub(Gitlab::class), new ConfigLoader(), new Runner()); $output = new BufferedOutput(); $cmd->run(new ArgvInput(['danger', 'test', '1']), $output); @@ -36,10 +36,10 @@ public function testInvalidConfig(): void { $_SERVER['DANGER_GITLAB_TOKEN'] = '1'; - $cmd = new GitlabCommand($this->createMock(Gitlab::class), new ConfigLoader(), new Runner()); + $cmd = new GitlabCommand(static::createStub(Gitlab::class), new ConfigLoader(), new Runner()); static::expectException(\InvalidArgumentException::class); - static::expectExceptionMessage('Invalid config option given'); + static::expectExceptionMessageIsOrContains('Invalid config option given'); $input = new ArgvInput(['danger', 'https://github.com']); $input->bind($cmd->getDefinition()); diff --git a/tests/Command/LocalCommandTest.php b/tests/Command/LocalCommandTest.php index ab2c56c7..3ffa5528 100644 --- a/tests/Command/LocalCommandTest.php +++ b/tests/Command/LocalCommandTest.php @@ -22,10 +22,10 @@ class LocalCommandTest extends TestCase { public function testInvalidConfig(): void { - $cmd = new LocalCommand(new ConfigLoader(), new Runner(), $this->createMock(LocalPlatform::class)); + $cmd = new LocalCommand(new ConfigLoader(), new Runner(), static::createStub(LocalPlatform::class)); static::expectException(\InvalidArgumentException::class); - static::expectExceptionMessage('Invalid config option given'); + static::expectExceptionMessageIsOrContains('Invalid config option given'); $input = new ArgvInput(['danger']); $input->bind($cmd->getDefinition()); @@ -36,10 +36,10 @@ public function testInvalidConfig(): void public function testInvalidRoot(): void { - $cmd = new LocalCommand(new ConfigLoader(), new Runner(), $this->createMock(LocalPlatform::class)); + $cmd = new LocalCommand(new ConfigLoader(), new Runner(), static::createStub(LocalPlatform::class)); static::expectException(\InvalidArgumentException::class); - static::expectExceptionMessage('Invalid root option given'); + static::expectExceptionMessageIsOrContains('Invalid root option given'); $input = new ArgvInput(['danger']); $input->bind($cmd->getDefinition()); @@ -72,7 +72,7 @@ public function testCommand(): void (new Filesystem())->remove($tmpDir); (new Process(['git', 'clone', 'file://' . $tmpDirTarget, $tmpDir]))->mustRun(); - $cmd = new LocalCommand(new ConfigLoader(), new Runner(), $this->createMock(LocalPlatform::class)); + $cmd = new LocalCommand(new ConfigLoader(), new Runner(), static::createStub(LocalPlatform::class)); $input = new ArgvInput(['danger', '--config=' . \dirname(__DIR__) . '/configs/empty.php', '--root=' . $tmpDir]); $input->bind($cmd->getDefinition()); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index c1693ac4..78cc2455 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -55,7 +55,7 @@ public function testGetReportLevelNotice(): void { $config = new Config(); - $context = new Context($this->createMock(AbstractPlatform::class)); + $context = new Context(static::createStub(AbstractPlatform::class)); $context->notice('test'); static::assertSame(Config::REPORT_LEVEL_NOTICE, $config->getReportLevel($context)); @@ -65,7 +65,7 @@ public function testGetReportLevelNone(): void { $config = new Config(); - $context = new Context($this->createMock(AbstractPlatform::class)); + $context = new Context(static::createStub(AbstractPlatform::class)); static::assertSame(Config::REPORT_LEVEL_NONE, $config->getReportLevel($context)); } diff --git a/tests/Platform/Github/GithubCommenterTest.php b/tests/Platform/Github/GithubCommenterTest.php index d4ab4fe2..555cd858 100644 --- a/tests/Platform/Github/GithubCommenterTest.php +++ b/tests/Platform/Github/GithubCommenterTest.php @@ -34,7 +34,7 @@ public function testCommentUsingProxyFails(): void static::expectException(\RuntimeException::class); - $commenter = new GithubCommenter($this->createMock(Client::class), $client); + $commenter = new GithubCommenter(static::createStub(Client::class), $client); $commenter->comment( 'test', 'test', @@ -50,7 +50,7 @@ public function testCommentUsingProxy(): void new MockResponse('{"html_url": "https://test.de"}', ['http_response' => 200, 'response_headers' => ['content-type' => 'application/json']]), ]); - $commenter = new GithubCommenter($this->createMock(Client::class), $client); + $commenter = new GithubCommenter(static::createStub(Client::class), $client); static::assertSame('https://test.de', $commenter->comment( 'test', 'test', @@ -66,7 +66,7 @@ public function testRemoveCommentUsingProxy(): void new MockResponse('{}', ['http_response' => 200, 'response_headers' => ['content-type' => 'application/json']]), ]); - $commenter = new GithubCommenter($this->createMock(Client::class), $client); + $commenter = new GithubCommenter(static::createStub(Client::class), $client); $commenter->remove( 'test', 'test', diff --git a/tests/Platform/Github/GithubTest.php b/tests/Platform/Github/GithubTest.php index 26599632..ec593167 100644 --- a/tests/Platform/Github/GithubTest.php +++ b/tests/Platform/Github/GithubTest.php @@ -152,7 +152,7 @@ public function testRemovePost(): void public function testLabels(): void { - $commenter = $this->createMock(GithubCommenter::class); + $commenter = static::createStub(GithubCommenter::class); $httpClient = new MockHttpClient([ new MockResponse((string) file_get_contents(__DIR__ . '/payloads/pr.json'), ['http_code' => 200, 'response_headers' => ['content-type' => 'application/json']]), @@ -179,7 +179,7 @@ public function testLabels(): void public function testLabelsWithoutPermission(): void { - $commenter = $this->createMock(GithubCommenter::class); + $commenter = static::createStub(GithubCommenter::class); $httpClient = new MockHttpClient([ new MockResponse((string) file_get_contents(__DIR__ . '/payloads/pr.json'), ['http_code' => 200, 'response_headers' => ['content-type' => 'application/json']]), @@ -202,7 +202,7 @@ public function testLabelsWithoutPermission(): void public function testAddLabelOtherErrorNotIgnored(): void { - $commenter = $this->createMock(GithubCommenter::class); + $commenter = static::createStub(GithubCommenter::class); $httpClient = new MockHttpClient([ new MockResponse((string) file_get_contents(__DIR__ . '/payloads/pr.json'), ['http_code' => 200, 'response_headers' => ['content-type' => 'application/json']]), @@ -217,14 +217,14 @@ public function testAddLabelOtherErrorNotIgnored(): void $github->load('FriendsOfShopware/FroshPluginUploader', '144'); static::expectException(\RuntimeException::class); - static::expectExceptionMessage('Permission Denied'); + static::expectExceptionMessageIsOrContains('Permission Denied'); $github->addLabels('Test'); } public function testRemoveLabelOtherErrorNotIgnored(): void { - $commenter = $this->createMock(GithubCommenter::class); + $commenter = static::createStub(GithubCommenter::class); $httpClient = new MockHttpClient([ new MockResponse((string) file_get_contents(__DIR__ . '/payloads/pr.json'), ['http_code' => 200, 'response_headers' => ['content-type' => 'application/json']]), @@ -239,14 +239,14 @@ public function testRemoveLabelOtherErrorNotIgnored(): void $github->load('FriendsOfShopware/FroshPluginUploader', '144'); static::expectException(\RuntimeException::class); - static::expectExceptionMessage('Permission Denied'); + static::expectExceptionMessageIsOrContains('Permission Denied'); $github->removeLabels('Test'); } public function testHasDangerComment(): void { - $commenter = $this->createMock(GithubCommenter::class); + $commenter = static::createStub(GithubCommenter::class); $commenter->method('getCommentIds')->willReturn([1]); $httpClient = new MockHttpClient([ @@ -265,7 +265,7 @@ public function testHasDangerComment(): void public function testFetchingHeadFile(): void { - $commenter = $this->createMock(GithubCommenter::class); + $commenter = static::createStub(GithubCommenter::class); $commenter->method('getCommentIds')->willReturn([1]); $httpClient = new MockHttpClient([ @@ -286,7 +286,7 @@ public function testFetchingHeadFile(): void public function testFetchingHeadFileFails(): void { - $commenter = $this->createMock(GithubCommenter::class); + $commenter = static::createStub(GithubCommenter::class); $commenter->method('getCommentIds')->willReturn([1]); $httpClient = new MockHttpClient([ @@ -302,7 +302,7 @@ public function testFetchingHeadFileFails(): void $github->load('FriendsOfShopware/FroshPluginUploader', '144'); static::expectException(CouldNotGetFileContentException::class); - static::expectExceptionMessage('Could not get content of file composer.json'); + static::expectExceptionMessageIsOrContains('Could not get content of file composer.json'); $github->pullRequest->getFileContent('composer.json'); } diff --git a/tests/Platform/Gitlab/GitlabTest.php b/tests/Platform/Gitlab/GitlabTest.php index f781667e..648f572f 100644 --- a/tests/Platform/Gitlab/GitlabTest.php +++ b/tests/Platform/Gitlab/GitlabTest.php @@ -158,7 +158,7 @@ public function testLabels(): void $client = Client::createWithHttpClient(new Psr18Client($mockHttpClient)); - $gitlab = new Gitlab($client, $this->createMock(GitlabCommenter::class)); + $gitlab = new Gitlab($client, static::createStub(GitlabCommenter::class)); $gitlab->load('test', '1'); $gitlab->removeLabels('Test'); @@ -177,7 +177,7 @@ public function testHasDangerComment(): void ]); $client = Client::createWithHttpClient(new Psr18Client($mockHttpClient)); - $commenter = $this->createMock(GitlabCommenter::class); + $commenter = static::createStub(GitlabCommenter::class); $commenter->method('getRelevantNoteIds')->willReturn([1, 2, 3]); $gitlab = new Gitlab($client, $commenter); @@ -195,7 +195,7 @@ public function testFetchingHeadFile(): void $client = Client::createWithHttpClient(new Psr18Client($mockHttpClient)); - $gitlab = new Gitlab($client, $this->createMock(GitlabCommenter::class)); + $gitlab = new Gitlab($client, static::createStub(GitlabCommenter::class)); $gitlab->load('test', '1'); $file = $gitlab->pullRequest->getFileContent('composer.json'); @@ -211,11 +211,11 @@ public function testFetchingHeadFileFails(): void $client = Client::createWithHttpClient(new Psr18Client($mockHttpClient)); - $gitlab = new Gitlab($client, $this->createMock(GitlabCommenter::class)); + $gitlab = new Gitlab($client, static::createStub(GitlabCommenter::class)); $gitlab->load('test', '1'); static::expectException(CouldNotGetFileContentException::class); - static::expectExceptionMessage('Could not get content of file composer.json'); + static::expectExceptionMessageIsOrContains('Could not get content of file composer.json'); $gitlab->pullRequest->getFileContent('composer.json'); } diff --git a/tests/Platform/PlatformDetectorTest.php b/tests/Platform/PlatformDetectorTest.php index c7ff8204..02f8ebce 100644 --- a/tests/Platform/PlatformDetectorTest.php +++ b/tests/Platform/PlatformDetectorTest.php @@ -16,9 +16,9 @@ class PlatformDetectorTest extends TestCase { public function testUnknown(): void { - $detector = new PlatformDetector($this->createMock(Github::class), $this->createMock(Gitlab::class)); + $detector = new PlatformDetector(static::createStub(Github::class), static::createStub(Gitlab::class)); static::expectException(UnsupportedCIException::class); - static::expectExceptionMessage('Could not detect CI Platform'); + static::expectExceptionMessageIsOrContains('Could not detect CI Platform'); $detector->detect(); } @@ -31,7 +31,7 @@ public function testGithub(): void $github = $this->createMock(Github::class); $github->expects(static::once())->method('load'); - $detector = new PlatformDetector($github, $this->createMock(Gitlab::class)); + $detector = new PlatformDetector($github, static::createStub(Gitlab::class)); static::assertSame($github, $detector->detect()); unset($_SERVER['GITHUB_REPOSITORY'], $_SERVER['GITHUB_PULL_REQUEST_ID'], $_SERVER['GITHUB_TOKEN']); @@ -47,7 +47,7 @@ public function testGitlab(): void $gitlab = $this->createMock(Gitlab::class); $gitlab->expects(static::once())->method('load'); - $detector = new PlatformDetector($this->createMock(Github::class), $gitlab); + $detector = new PlatformDetector(static::createStub(Github::class), $gitlab); static::assertSame($gitlab, $detector->detect()); unset($_SERVER['GITLAB_CI'], $_SERVER['CI_PROJECT_ID'], $_SERVER['CI_MERGE_REQUEST_IID'], $_SERVER['DANGER_GITLAB_TOKEN']); diff --git a/tests/Renderer/HTMLRendererTest.php b/tests/Renderer/HTMLRendererTest.php index 57f69d88..3471411a 100644 --- a/tests/Renderer/HTMLRendererTest.php +++ b/tests/Renderer/HTMLRendererTest.php @@ -16,13 +16,13 @@ class HTMLRendererTest extends TestCase public function testRenderEmpty(): void { $renderer = new HTMLRenderer(); - static::assertSame(HTMLRenderer::MARKER, $renderer->convert(new Context($this->createMock(Github::class)))); + static::assertSame(HTMLRenderer::MARKER, $renderer->convert(new Context(static::createStub(Github::class)))); } public function testRenderFailure(): void { $renderer = new HTMLRenderer(); - $context = new Context($this->createMock(Github::class)); + $context = new Context(static::createStub(Github::class)); $context->failure('Test'); static::assertStringContainsString(HTMLRenderer::MARKER, $renderer->convert($context)); diff --git a/tests/Rule/CheckPhpCsFixerTest.php b/tests/Rule/CheckPhpCsFixerTest.php index 11f1c384..fca2b4ed 100644 --- a/tests/Rule/CheckPhpCsFixerTest.php +++ b/tests/Rule/CheckPhpCsFixerTest.php @@ -18,8 +18,8 @@ class CheckPhpCsFixerTest extends TestCase { public function testRuleRunsWithoutIssues(): void { - $github = $this->createMock(Github::class); - $pullRequest = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pullRequest = static::createStub(PullRequest::class); $github->pullRequest = $pullRequest; $pullRequest->method('getFiles')->willReturn(new FileCollection([ new TestFile('test.php', 'createMock(Github::class); - $pullRequest = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pullRequest = static::createStub(PullRequest::class); $github->pullRequest = $pullRequest; $pullRequest->method('getFiles')->willReturn(new FileCollection([ new TestFile('test.php', 'createMock(Github::class); + $github = static::createStub(Github::class); $context = new Context($github); $rule = new CheckPhpStan(); @@ -26,7 +26,7 @@ public function testValid(): void public function testInvalid(): void { - $github = $this->createMock(Github::class); + $github = static::createStub(Github::class); $context = new Context($github); $path = \dirname(__DIR__, 2) . '/src/Test.php'; diff --git a/tests/Rule/CommitRegexTest.php b/tests/Rule/CommitRegexTest.php index 6f05c79d..75f7ea73 100644 --- a/tests/Rule/CommitRegexTest.php +++ b/tests/Rule/CommitRegexTest.php @@ -21,8 +21,8 @@ public function testRuleMatches(): void $commit = new Commit(); $commit->message = 'Test'; - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([$commit])); $github->pullRequest = $pr; @@ -39,8 +39,8 @@ public function testRuleNotMatches(): void $commit = new Commit(); $commit->message = 'feat: Test'; - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([$commit])); $github->pullRequest = $pr; diff --git a/tests/Rule/ConditionTest.php b/tests/Rule/ConditionTest.php index ff0157af..ba3002cd 100644 --- a/tests/Rule/ConditionTest.php +++ b/tests/Rule/ConditionTest.php @@ -16,7 +16,7 @@ class ConditionTest extends TestCase { public function testConditionMet(): void { - $github = $this->createMock(Github::class); + $github = static::createStub(Github::class); $context = new Context($github); $innerRuleExecuted = false; @@ -36,7 +36,7 @@ static function () use (&$innerRuleExecuted): void { public function testConditionNotMet(): void { - $github = $this->createMock(Github::class); + $github = static::createStub(Github::class); $context = new Context($github); $innerRuleExecuted = false; diff --git a/tests/Rule/DisallowRepeatedCommitsTest.php b/tests/Rule/DisallowRepeatedCommitsTest.php index 1701bbbe..1516bc45 100644 --- a/tests/Rule/DisallowRepeatedCommitsTest.php +++ b/tests/Rule/DisallowRepeatedCommitsTest.php @@ -24,8 +24,8 @@ public function testRuleMatches(): void $secondCommit = new Commit(); $secondCommit->message = 'Test'; - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([$commit, $secondCommit])); $github->pullRequest = $pr; @@ -45,8 +45,8 @@ public function testRuleNotMatches(): void $secondCommit = new Commit(); $secondCommit->message = 'Test2'; - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([$commit, $secondCommit])); $github->pullRequest = $pr; @@ -69,8 +69,8 @@ public function testRuleMatchesWithMergeCommits(): void $thirdCommit = new Commit(); $thirdCommit->message = 'Merge branch master into feature'; - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([$commit, $secondCommit, $thirdCommit])); $github->pullRequest = $pr; @@ -93,8 +93,8 @@ public function testRuleNotMatchesWithMultipleMergeCommits(): void $thirdCommit = new Commit(); $thirdCommit->message = 'Merge branch master into feature'; - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([$commit, $secondCommit, $thirdCommit])); $github->pullRequest = $pr; diff --git a/tests/Rule/MaxCommitTest.php b/tests/Rule/MaxCommitTest.php index 7e7ca500..e4be5198 100644 --- a/tests/Rule/MaxCommitTest.php +++ b/tests/Rule/MaxCommitTest.php @@ -18,8 +18,8 @@ class MaxCommitTest extends TestCase { public function testRuleMatches(): void { - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([new Commit(), new Commit()])); $github->pullRequest = $pr; @@ -33,8 +33,8 @@ public function testRuleMatches(): void public function testRuleNotMatches(): void { - $github = $this->createMock(Github::class); - $pr = $this->createMock(PullRequest::class); + $github = static::createStub(Github::class); + $pr = static::createStub(PullRequest::class); $pr->method('getCommits')->willReturn(new CommitCollection([new Commit()])); $github->pullRequest = $pr; diff --git a/tests/RunnerTest.php b/tests/RunnerTest.php index f625aa14..0e27efda 100644 --- a/tests/RunnerTest.php +++ b/tests/RunnerTest.php @@ -33,7 +33,7 @@ public function testRunner(): void }); $config->useThreadOn(Config::REPORT_LEVEL_FAILURE); - $runner->run($config, new Context($this->createMock(Github::class))); + $runner->run($config, new Context(static::createStub(Github::class))); static::assertTrue($ruleExecuted); static::assertTrue($afterExecuted);