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

DEP Use PHPUnit 11 #96

Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"bringyourownideas/silverstripe-maintenance": "^4"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^11.3",
"squizlabs/php_codesniffer": "^3",
"silverstripe/standards": "^1",
"phpstan/extension-installer": "^1.3"
Expand Down
6 changes: 3 additions & 3 deletions tests/Extensions/CheckComposerUpdatesExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function setUp(): void
$this->task = UpdatePackageInfoTask::create();

// Create a partial mock of the update checker
$updateCheckerMock = $this->getMockBuilder(UpdateChecker::class)->setMethods(['checkForUpdates'])->getMock();
$updateCheckerMock = $this->getMockBuilder(UpdateChecker::class)->onlyMethods(['checkForUpdates'])->getMock();
$this->task->setUpdateChecker($updateCheckerMock);

$this->allowedTypes = ['silverstripe-module', 'silverstripe-vendormodule', 'silverstripe-theme'];
Expand All @@ -55,7 +55,7 @@ public function testRunPassesPackagesToUpdateChecker()
$this->task->getUpdateChecker()->expects($this->atLeastOnce())
->method('checkForUpdates')
->with($this->isInstanceOf(PackageInterface::class), $this->isType('string'))
->will($this->returnValue([]));
->willReturn([]);

$this->runTask();
}
Expand All @@ -67,7 +67,7 @@ public function testOnlyAllowedPackageTypesAreProcessed()
->with($this->callback(function ($argument) {
return in_array($argument->getType(), $this->allowedTypes);
}))
->will($this->returnValue([]));
->willReturn([]);

$this->runTask();
}
Expand Down
18 changes: 12 additions & 6 deletions tests/UpdateCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ protected function setUp(): void

// Mock composer and composer loader
$composer = $this->getMockBuilder(Composer::class)->getMock();
$composerLoader = $this->getMockBuilder(ComposerLoader::class)
->disableOriginalConstructor()
->setMethods(['getComposer'])
->getMock();
$composerLoader->expects($this->once())->method('getComposer')->will($this->returnValue($composer));
$composerLoader = new class ($composer) extends ComposerLoader {
private $composer;
public function __construct($composer)
{
$this->composer = $composer;
}
public function getComposer(): Composer
{
return $this->composer;
}
};
Injector::inst()->registerService($composerLoader, ComposerLoader::class);

// Partially mock UpdateChecker
$this->updateChecker = $this->getMockBuilder(UpdateChecker::class)
->setMethods(['findLatestPackage'])
->onlyMethods(['findLatestPackage'])
->getMock();
}

Expand Down
Loading