DEP Use PHPUnit 11

This commit is contained in:
Steve Boyd 2024-09-12 11:03:37 +12:00
parent 57f7f5b45e
commit 465bd1a83f
3 changed files with 15 additions and 7 deletions

View File

@ -22,7 +22,7 @@
], ],
"require": { "require": {
"php": "^8.3", "php": "^8.3",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^11.3",
"squizlabs/php_codesniffer": "^3.7", "squizlabs/php_codesniffer": "^3.7",
"behat/behat": "^3.11.0", "behat/behat": "^3.11.0",
"behat/mink": "^1.10.0", "behat/mink": "^1.10.0",

View File

@ -22,6 +22,9 @@ use Symfony\Component\DependencyInjection\Reference;
use Behat\Behat\Tester\ServiceContainer\TesterExtension; use Behat\Behat\Tester\ServiceContainer\TesterExtension;
use SilverStripe\BehatExtension\Utility\RerunTotalStatistics; use SilverStripe\BehatExtension\Utility\RerunTotalStatistics;
use SilverStripe\BehatExtension\Utility\RerunRuntimeSuiteTester; 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 * This file is part of the SilverStripe\BehatExtension
@ -76,6 +79,11 @@ class Extension implements ExtensionInterface
if (!$found) { if (!$found) {
throw new RuntimeException('Could not find PHPUnit installation'); 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) public function load(ContainerBuilder $container, array $config)

View File

@ -40,7 +40,7 @@ class SilverStripeContextTest extends SapphireTest
$context->getSession()->getPage() $context->getSession()->getPage()
->expects($this->any()) ->expects($this->any())
->method('find') ->method('find')
->will($this->returnValue($this->getElementMock())); ->willReturn($this->getElementMock());
$obj = $context->getRegionObj('.some-selector'); $obj = $context->getRegionObj('.some-selector');
$this->assertNotNull($obj); $this->assertNotNull($obj);
} }
@ -52,9 +52,9 @@ class SilverStripeContextTest extends SapphireTest
$context->getSession()->getPage() $context->getSession()->getPage()
->expects($this->any()) ->expects($this->any())
->method('find') ->method('find')
->will($this->returnCallback(function ($type, $selector) use ($el) { ->willReturnCallback(function ($type, $selector) use ($el) {
return ($selector == '.my-region') ? $el : null; return ($selector == '.my-region') ? $el : null;
})); });
$context->setRegionMap(array('MyRegion' => '.my-asdf')); $context->setRegionMap(array('MyRegion' => '.my-asdf'));
$obj = $context->getRegionObj('.my-region'); $obj = $context->getRegionObj('.my-region');
$this->assertNotNull($obj); $this->assertNotNull($obj);
@ -67,18 +67,18 @@ class SilverStripeContextTest extends SapphireTest
{ {
$pageMock = $this->getMockBuilder(DocumentElement::class) $pageMock = $this->getMockBuilder(DocumentElement::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(array('find')) ->onlyMethods(array('find'))
->getMock(); ->getMock();
$sessionMock = $this->getMockBuilder(Session::class) $sessionMock = $this->getMockBuilder(Session::class)
->setConstructorArgs(array( ->setConstructorArgs(array(
$this->getMockBuilder(DriverInterface::class)->getMock(), $this->getMockBuilder(DriverInterface::class)->getMock(),
$this->getMockBuilder(SelectorsHandler::class)->getMock() $this->getMockBuilder(SelectorsHandler::class)->getMock()
)) ))
->setMethods(array('getPage')) ->onlyMethods(array('getPage'))
->getMock(); ->getMock();
$sessionMock->expects($this->any()) $sessionMock->expects($this->any())
->method('getPage') ->method('getPage')
->will($this->returnValue($pageMock)); ->willReturn($pageMock);
$mink = new Mink(array('default' => $sessionMock)); $mink = new Mink(array('default' => $sessionMock));
$mink->setDefaultSessionName('default'); $mink->setDefaultSessionName('default');