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 #284

Merged
merged 1 commit into from
Sep 18, 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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"require": {
"php": "^8.3",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^11.3",
"squizlabs/php_codesniffer": "^3.7",
"behat/behat": "^3.11.0",
"behat/mink": "^1.10.0",
Expand Down
8 changes: 8 additions & 0 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
use Behat\Behat\Tester\ServiceContainer\TesterExtension;
use SilverStripe\BehatExtension\Utility\RerunTotalStatistics;
use SilverStripe\BehatExtension\Utility\RerunRuntimeSuiteTester;
use PHPUnit\TextUI\CliArguments\Builder;
use PHPUnit\TextUI\Configuration\Registry;
use PHPUnit\TextUI\XmlConfiguration\DefaultConfiguration;

/*
* This file is part of the SilverStripe\BehatExtension
Expand Down Expand Up @@ -76,6 +79,11 @@ public function initialize(ExtensionManager $extensionManager)
if (!$found) {
throw new RuntimeException('Could not find PHPUnit installation');
}

// Need to init phpunit app registry to get phpunit exporter to work
$cliConfiguration = (new Builder)->fromParameters([]);
$xmlConfiguration = DefaultConfiguration::create();
Registry::init($cliConfiguration, $xmlConfiguration);
}

public function load(ContainerBuilder $container, array $config)
Expand Down
12 changes: 6 additions & 6 deletions tests/php/SilverStripeContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testGetRegionObjFindsBySelector()
$context->getSession()->getPage()
->expects($this->any())
->method('find')
->will($this->returnValue($this->getElementMock()));
->willReturn($this->getElementMock());
$obj = $context->getRegionObj('.some-selector');
$this->assertNotNull($obj);
}
Expand All @@ -52,9 +52,9 @@ public function testGetRegionObjFindsByRegion()
$context->getSession()->getPage()
->expects($this->any())
->method('find')
->will($this->returnCallback(function ($type, $selector) use ($el) {
->willReturnCallback(function ($type, $selector) use ($el) {
return ($selector == '.my-region') ? $el : null;
}));
});
$context->setRegionMap(array('MyRegion' => '.my-asdf'));
$obj = $context->getRegionObj('.my-region');
$this->assertNotNull($obj);
Expand All @@ -67,18 +67,18 @@ protected function getContextMock()
{
$pageMock = $this->getMockBuilder(DocumentElement::class)
->disableOriginalConstructor()
->setMethods(array('find'))
->onlyMethods(array('find'))
->getMock();
$sessionMock = $this->getMockBuilder(Session::class)
->setConstructorArgs(array(
$this->getMockBuilder(DriverInterface::class)->getMock(),
$this->getMockBuilder(SelectorsHandler::class)->getMock()
))
->setMethods(array('getPage'))
->onlyMethods(array('getPage'))
->getMock();
$sessionMock->expects($this->any())
->method('getPage')
->will($this->returnValue($pageMock));
->willReturn($pageMock);
$mink = new Mink(array('default' => $sessionMock));
$mink->setDefaultSessionName('default');

Expand Down
Loading