Skip to content

Commit

Permalink
Merge pull request #96 from creative-commoners/pulls/5/phpunit11
Browse files Browse the repository at this point in the history
DEP Use PHPUnit 11
  • Loading branch information
GuySartorelli authored Sep 18, 2024
2 parents 7ec468a + 3dffbab commit e729f07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
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

0 comments on commit e729f07

Please sign in to comment.