Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace most usages of deprecated PHPUnit setMethods() function #2086

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Get rid of removed function setMethods()
Co-authored-by: William Allen <16820599+williamjallen@users.noreply.github.com>
  • Loading branch information
sbelsk and williamjallen committed Mar 16, 2024
commit 7a6d6675ee1c0ca97cb89fe9b8d396048ca4e062
2 changes: 1 addition & 1 deletion app/cdash/include/Test/BuildDiffForTesting.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function createMockBuildWithDiff($diff)
{
/** @var Build|PHPUnit_Framework_MockObject_MockObject $build */
$build = $this->getMockBuilder(Build::class)
->setMethods(['GetErrorDifferences', 'GetPreviousBuildId'])
->onlyMethods(['GetErrorDifferences', 'GetPreviousBuildId'])
->getMock();

$build->expects($this->any())
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/include/Test/CDashUseCaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUseCaseModelFactory(UseCase $useCase)

$mockServiceContainer = $this->getMockBuilder(ServiceContainer::class)
->disableOriginalConstructor()
->setMethods(['create'])
->onlyMethods(['create'])
->getMock();

$mockServiceContainer
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/case/CDash/Api/GitHubWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUp() : void

$this->mock_system = $this->getMockBuilder(System::class)
->disableOriginalConstructor()
->setMethods(['system_exit'])
->onlyMethods(['system_exit'])
->getMock();
$container->set(System::class, $this->mock_system);

Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/case/CDash/Lib/Repository/GitHubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private function setupAuthentication()

$client = $this->getMockBuilder(\Github\Client::class)
->disableOriginalConstructor()
->setMethods(['api', 'authenticate', 'getHttpClient'])
->onlyMethods(['api', 'authenticate', 'getHttpClient'])
->getMock();
$client->expects($this->any())
->method('authenticate');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getMockSubmission($key, $handler_class)
/** @var BuildGroup|PHPUnit_Framework_MockObject_MockObject $mock_group */
$mock_group = $this->getMockBuilder(BuildGroup::class)
->disableOriginalConstructor()
->setMethods(['isNotifyingCommitters'])
->onlyMethods(['isNotifyingCommitters'])
->getMock();

$mock_group->expects($this->any())
Expand All @@ -123,7 +123,7 @@ public function getMockSubmission($key, $handler_class)
/** @var ActionableBuildInterface|PHPUnit_Framework_MockObject_MockObject $mock_handler */
$mock_handler = $this->getMockBuilder($handler_class)
->disableOriginalConstructor()
->setMethods(['GetProject', 'GetSite', 'GetBuildCollection', 'GetCommitAuthors', 'GetBuildGroup', 'GetTopicCollectionForSubscriber'])
->onlyMethods(['GetProject', 'GetSite', 'GetBuildCollection', 'GetCommitAuthors', 'GetBuildGroup', 'GetTopicCollectionForSubscriber'])
->getMock();

$mock_handler->expects($this->any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function getMockHandler(BuildCollection $builds)
->getMockForAbstractClass();

$mock_project = $this->getMockBuilder(Project::class)
->setMethods(['GetSubscriberCollection'])
->onlyMethods(['GetSubscriberCollection'])
->getMock();

$mock_project->expects($this->any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testSubscribesToBuild()

/** @var Build|PHPUnit_Framework_MockObject_MockObject $build */
$build = $this->getMockBuilder(Build::class)
->setMethods(['GetCommitAuthors'])
->onlyMethods(['GetCommitAuthors'])
->getMock();

$build->expects($this->exactly(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function testHasFixes()

/** @var Build|PHPUnit_Framework_MockObject_MockObject $build */
$build = $this->getMockBuilder(Build::class)
->setMethods(['GetErrorDifferences'])
->onlyMethods(['GetErrorDifferences'])
->getMock();

$build->expects($this->never())
Expand All @@ -185,7 +185,7 @@ public function testHasFixes()
$this->assertFalse($sut->hasFixes());

$build = $this->getMockBuilder(Build::class)
->setMethods(['GetErrorDifferences', 'GetPreviousBuildId'])
->onlyMethods(['GetErrorDifferences', 'GetPreviousBuildId'])
->getMock();

$build->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testSubscribesToBuild()

/** @var Build|PHPUnit_Framework_MockObject_MockObject $build1 */
$build1 = $this->getMockBuilder(Build::class)
->setMethods(['GetMissingTests'])
->onlyMethods(['GetMissingTests'])
->getMock();

$build1->expects($this->once())
Expand All @@ -39,7 +39,7 @@ public function testSubscribesToBuild()

/** @var Build|PHPUnit_Framework_MockObject_MockObject $build2 */
$build2 = $this->getMockBuilder(Build::class)
->setMethods(['GetMissingTests'])
->onlyMethods(['GetMissingTests'])
->getMock();

$build2->expects($this->once())
Expand Down Expand Up @@ -86,7 +86,7 @@ public function testSetTopicData()

/** @var Build|PHPUnit_Framework_MockObject_MockObject $build2 */
$build2 = $this->getMockBuilder(Build::class)
->setMethods(['GetMissingTests'])
->onlyMethods(['GetMissingTests'])
->getMock();

$build2->expects($this->any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function testSubscribesToRedundantBuild()
$diff = $this->createNew('testfailedpositive');
$diff['testfailedpositive'] = 0;
$build = $this->getMockBuilder(Build::class)
->setMethods(['GetErrorDifferences', 'GetPreviousBuildId', 'GetNumberOfFailedTests'])
->onlyMethods(['GetErrorDifferences', 'GetPreviousBuildId', 'GetNumberOfFailedTests'])
->getMock();
$build->expects($this->any())
->method('GetErrorDifferences')
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/case/CDash/Model/BuildFailureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function setUp() : void
$container = ServiceContainer::container();
$this->mock_buildfailure = $this->getMockBuilder(BuildFailure::class)
->disableOriginalConstructor()
->setMethods(['GetBuildFailureArguments'])
->onlyMethods(['GetBuildFailureArguments'])
->getMock();
$this->mock_project = $this->getMockBuilder(Project::class)
->disableOriginalConstructor()
Expand Down
4 changes: 2 additions & 2 deletions app/cdash/tests/case/CDash/Model/BuildRelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public function setUp() : void

$this->mock_build1 = $this->getMockBuilder(Build::class)
->disableOriginalConstructor()
->setMethods(['Exists', 'FillFromId'])
->onlyMethods(['Exists', 'FillFromId'])
->getMock();
$this->mock_build1->Id = 1;
$this->mock_build1->ProjectId = 1;
$container->set(Build::class, $this->mock_build1);

$this->mock_build2 = $this->getMockBuilder(Build::class)
->disableOriginalConstructor()
->setMethods(['Exists', 'FillFromId'])
->onlyMethods(['Exists', 'FillFromId'])
->getMock();
$this->mock_build2->Id = 2;
$this->mock_build2->ProjectId = 1;
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/case/CDash/Model/BuildTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGetBuildEmailCollection()
// TODO: refactor asap
/** @var Build|PHPUnit_Framework_MockObject_MockObject $sut */
$sut = $this->getMockBuilder(Build::class)
->setMethods(['GetErrorDifferences', 'GetPreviousBuildId'])
->onlyMethods(['GetErrorDifferences', 'GetPreviousBuildId'])
->getMock();
$sut->Id = 1;
$sut->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function setUp() : void

$this->mock_build = $this->getMockBuilder(Build::class)
->disableOriginalConstructor()
->setMethods(['Exists', 'FillFromId'])
->onlyMethods(['Exists', 'FillFromId'])
->getMock();
$this->mock_build->Id = 1;
$this->mock_build->ProjectId = 1;
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/case/CDash/Model/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setUp() : void

$this->project = $this->getMockBuilder(Project::class)
->disableOriginalConstructor()
->setMethods(['GetRepositories'])
->onlyMethods(['GetRepositories'])
->getMock();

$this->project->CvsViewerType = Repository::VIEWER_GITHUB;
Expand Down
4 changes: 2 additions & 2 deletions app/cdash/tests/case/CDash/ServiceContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testCreate()
{
$mock_di = $this->getMockBuilder(DI\Container::class)
->disableOriginalConstructor()
->setMethods(['make'])
->onlyMethods(['make'])
->getMock();

$mock_di
Expand All @@ -61,7 +61,7 @@ public function testGet()
{
$mock_di = $this->getMockBuilder(DI\Container::class)
->disableOriginalConstructor()
->setMethods(['get'])
->onlyMethods(['get'])
->getMock();

$mock_di
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public function testGetCommitAuthors()
{
$has_errors = $this->getMockBuilder(Build::class)
->disableOriginalConstructor()
->setMethods(['GetCommitAuthors'])
->onlyMethods(['GetCommitAuthors'])
->getMock();

$has_warnings = $this->getMockBuilder(Build::class)
->disableOriginalConstructor()
->setMethods(['GetCommitAuthors'])
->onlyMethods(['GetCommitAuthors'])
->getMock();

$has_errors->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testUpdateHandlerIsACommitAuthorHandler()
public function testGetCommitAuthors()
{
$build = $this->getMockBuilder(Build::class)
->setMethods(['GetCommitAuthors'])
->onlyMethods(['GetCommitAuthors'])
->disableOriginalConstructor()
->getMock();

Expand Down
Loading