From 81eed3bbc5d08414af3aa06d79e486dc33a8a18e Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 12 May 2023 10:52:57 +0200 Subject: [PATCH 1/5] chore: fix ci deprecations, add test-runs for php 8.2, allow phpunit 10 --- .github/workflows/tests.yml | 8 ++++---- .gitignore | 1 + composer.json | 2 +- tests/Driver/CoreDriverTest.php | 8 +++++++- tests/Exception/ElementNotFoundExceptionTest.php | 2 +- tests/Selector/NamedSelectorTest.php | 4 ++-- tests/Selector/Xpath/EscaperTest.php | 2 +- tests/Selector/Xpath/ManipulatorTest.php | 2 +- tests/SessionTest.php | 2 +- tests/WebAssertTest.php | 2 +- 10 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 674ca81b3..1fb09b891 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] composer_flags: [ '' ] minimum_stability: [ '' ] symfony_deprecations_helper: [ '' ] @@ -32,7 +32,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 1 @@ -55,9 +55,9 @@ jobs: - name: Run tests run: | export SYMFONY_DEPRECATIONS_HELPER="${{ matrix.symfony_deprecations_helper }}" - vendor/bin/phpunit -v --coverage-clover=coverage.xml + vendor/bin/phpunit --coverage-clover=coverage.xml - name: Upload coverage - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: files: coverage.xml diff --git a/.gitignore b/.gitignore index 961fea1d6..9750b4f88 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ *.phar phpunit.xml .phpunit.result.cache +.phpunit.cache composer.lock vendor diff --git a/composer.json b/composer.json index 5a2bb123d..435da510e 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require-dev": { "symfony/error-handler": "^4.4 || ^5.0 || ^6.0", - "phpunit/phpunit": "^8.5.22 || ^9.5.11", + "phpunit/phpunit": "^8.5.22 || ^9.6 || ^10.1", "symfony/phpunit-bridge": "^5.4 || ^6.0" }, diff --git a/tests/Driver/CoreDriverTest.php b/tests/Driver/CoreDriverTest.php index f4a597886..b2f145179 100644 --- a/tests/Driver/CoreDriverTest.php +++ b/tests/Driver/CoreDriverTest.php @@ -22,9 +22,15 @@ public function testNoExtraMethods() public function testCreateNodeElements() { + if(\PHPUnit\Runner\Version::id() >= 10) { + $driver = $this->getMockBuilder('Behat\Mink\Driver\CoreDriver') + ->onlyMethods(array('findElementXpaths')) + ->getMockForAbstractClass(); + } else { $driver = $this->getMockBuilder('Behat\Mink\Driver\CoreDriver') ->setMethods(array('findElementXpaths')) ->getMockForAbstractClass(); + } $session = $this->getMockBuilder('Behat\Mink\Session') ->disableOriginalConstructor() @@ -72,7 +78,7 @@ public function testInterfaceMethods(\ReflectionMethod $method) call_user_func_array(array($driver, $method->getName()), $this->getArguments($method)); } - public function getDriverInterfaceMethods() + public static function getDriverInterfaceMethods() { $ref = new \ReflectionClass('Behat\Mink\Driver\DriverInterface'); diff --git a/tests/Exception/ElementNotFoundExceptionTest.php b/tests/Exception/ElementNotFoundExceptionTest.php index 4ac30b0a3..b6b9aaad3 100644 --- a/tests/Exception/ElementNotFoundExceptionTest.php +++ b/tests/Exception/ElementNotFoundExceptionTest.php @@ -19,7 +19,7 @@ public function testBuildMessage($message, $type, $selector = null, $locator = n $this->assertEquals($message, $exception->getMessage()); } - public function provideExceptionMessage() + public static function provideExceptionMessage() { return array( array('Tag not found.', null), diff --git a/tests/Selector/NamedSelectorTest.php b/tests/Selector/NamedSelectorTest.php index 9dcbf71bd..eae58cdda 100644 --- a/tests/Selector/NamedSelectorTest.php +++ b/tests/Selector/NamedSelectorTest.php @@ -96,7 +96,7 @@ public function testEscapedSelectors($fixtureFile, $selector, $locator, $expecte $this->testSelectors($fixtureFile, $selector, $locator, $expectedExactCount, $expectedPartialCount); } - public function getSelectorTests() + public static function getSelectorTests() { $fieldCount = 8; // fields without `type` attribute $fieldCount += 4; // fields with `type=checkbox` attribute @@ -187,7 +187,7 @@ public function getSelectorTests() ); } - public function getLateRegisteredReplacements() + public static function getLateRegisteredReplacements() { // The following tests all use `test.html` from the fixtures directory. return array( diff --git a/tests/Selector/Xpath/EscaperTest.php b/tests/Selector/Xpath/EscaperTest.php index ea7944b76..83a0436e8 100644 --- a/tests/Selector/Xpath/EscaperTest.php +++ b/tests/Selector/Xpath/EscaperTest.php @@ -17,7 +17,7 @@ public function testXpathLiteral($string, $expected) $this->assertEquals($expected, $escaper->escapeLiteral($string)); } - public function getXpathLiterals() + public static function getXpathLiterals() { return array( array('some simple string', "'some simple string'"), diff --git a/tests/Selector/Xpath/ManipulatorTest.php b/tests/Selector/Xpath/ManipulatorTest.php index 51bed9f91..91cd7f4f6 100644 --- a/tests/Selector/Xpath/ManipulatorTest.php +++ b/tests/Selector/Xpath/ManipulatorTest.php @@ -17,7 +17,7 @@ public function testPrepend($prefix, $xpath, $expectedXpath) $this->assertEquals($expectedXpath, $manipulator->prepend($xpath, $prefix)); } - public function getPrependedXpath() + public static function getPrependedXpath() { return array( 'simple' => array( diff --git a/tests/SessionTest.php b/tests/SessionTest.php index cab731f51..9cead2ee6 100644 --- a/tests/SessionTest.php +++ b/tests/SessionTest.php @@ -176,7 +176,7 @@ public function testGetResponseHeader($expected, $name, array $headers) $this->assertSame($expected, $this->session->getResponseHeader($name)); } - public function provideResponseHeader() + public static function provideResponseHeader() { return array( array('test', 'Mink', array('Mink' => 'test')), diff --git a/tests/WebAssertTest.php b/tests/WebAssertTest.php index 22c58b7bc..6f844d25a 100644 --- a/tests/WebAssertTest.php +++ b/tests/WebAssertTest.php @@ -818,7 +818,7 @@ public function testElementNotExistsArrayLocator($selector, $locator, $expectedM ); } - public function getArrayLocatorFormats() + public static function getArrayLocatorFormats() { return array( 'named' => array( From bf8a96e27448f44d81bc505479cd60b1b4549f2b Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 12 May 2023 11:02:58 +0200 Subject: [PATCH 2/5] chore: fix ci deprecations, add test-runs for php 8.2, allow phpunit 10 --- composer.json | 2 +- phpunit.xml.dist | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 435da510e..74383e051 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require-dev": { "symfony/error-handler": "^4.4 || ^5.0 || ^6.0", - "phpunit/phpunit": "^8.5.22 || ^9.6 || ^10.1", + "phpunit/phpunit": "^8.5.33 || ^9.6 || ^10.1", "symfony/phpunit-bridge": "^5.4 || ^6.0" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9f6f546c5..edd365fa5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,21 @@ + + - - - - tests - - + + + tests + + - - - ./src - - + + + ./src + + - - - From bf9c7d101cc07f6b36a3b29913930094de973383 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 12 May 2023 11:26:16 +0200 Subject: [PATCH 3/5] chore: fix ci deprecations, add test-runs for php 8.2, allow phpunit 10 --- phpunit.xml.dist | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index edd365fa5..c6e58c932 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,7 +9,10 @@ tests + ./tests/Element/ElementTest.php + ./tests/Selector/NamedSelectorTest.php + From 440cdaaf87db097f61a2262575afb2c46ffbbb61 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 12 May 2023 12:44:29 +0200 Subject: [PATCH 4/5] chore: fix ci deprecations, add test-runs for php 8.2, allow phpunit 10 --- phpunit.xml.dist | 10 +++++++--- tests/Element/ElementTest.php | 8 +++++++- tests/Selector/ExactNamedSelectorTest.php | 5 ++++- ...SelectorTest.php => NamedSelectorTestTrait.php} | 14 +------------- tests/Selector/PartialNamedSelectorTest.php | 5 ++++- 5 files changed, 23 insertions(+), 19 deletions(-) rename tests/Selector/{NamedSelectorTest.php => NamedSelectorTestTrait.php} (98%) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c6e58c932..522ea9fe7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,10 +9,7 @@ tests - ./tests/Element/ElementTest.php - ./tests/Selector/NamedSelectorTest.php - @@ -21,4 +18,11 @@ + + diff --git a/tests/Element/ElementTest.php b/tests/Element/ElementTest.php index 885c1a963..a92b66a29 100644 --- a/tests/Element/ElementTest.php +++ b/tests/Element/ElementTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -abstract class ElementTest extends TestCase +class ElementTest extends TestCase { /** * Session. @@ -73,4 +73,10 @@ protected function mockNamedFinder($xpath, array $results, $locator, $times = 2) ->with($this->logicalOr('named_exact', 'named_partial'), $locator) ->will($this->returnValue($xpath)); } + + // just to suppress warnings from phpunit 10 of no tests found + public function testDummy() + { + self::assertTrue(true); + } } diff --git a/tests/Selector/ExactNamedSelectorTest.php b/tests/Selector/ExactNamedSelectorTest.php index df51f0fd7..11bee640d 100644 --- a/tests/Selector/ExactNamedSelectorTest.php +++ b/tests/Selector/ExactNamedSelectorTest.php @@ -3,9 +3,12 @@ namespace Behat\Mink\Tests\Selector; use Behat\Mink\Selector\ExactNamedSelector; +use PHPUnit\Framework\TestCase; -class ExactNamedSelectorTest extends NamedSelectorTest +class ExactNamedSelectorTest extends TestCase { + use NamedSelectorTestTrait; + protected function getSelector() { return new ExactNamedSelector(); diff --git a/tests/Selector/NamedSelectorTest.php b/tests/Selector/NamedSelectorTestTrait.php similarity index 98% rename from tests/Selector/NamedSelectorTest.php rename to tests/Selector/NamedSelectorTestTrait.php index eae58cdda..35da4a028 100644 --- a/tests/Selector/NamedSelectorTest.php +++ b/tests/Selector/NamedSelectorTestTrait.php @@ -2,11 +2,9 @@ namespace Behat\Mink\Tests\Selector; -use Behat\Mink\Selector\NamedSelector; use Behat\Mink\Selector\Xpath\Escaper; -use PHPUnit\Framework\TestCase; -abstract class NamedSelectorTest extends TestCase +trait NamedSelectorTestTrait { public function testRegisterXpath() { @@ -294,14 +292,4 @@ public static function getLateRegisteredReplacements() ), ); } - - /** - * @return NamedSelector - */ - abstract protected function getSelector(); - - /** - * @return bool - */ - abstract protected function allowPartialMatch(); } diff --git a/tests/Selector/PartialNamedSelectorTest.php b/tests/Selector/PartialNamedSelectorTest.php index c3e631a11..3298c57ff 100644 --- a/tests/Selector/PartialNamedSelectorTest.php +++ b/tests/Selector/PartialNamedSelectorTest.php @@ -3,9 +3,12 @@ namespace Behat\Mink\Tests\Selector; use Behat\Mink\Selector\PartialNamedSelector; +use PHPUnit\Framework\TestCase; -class PartialNamedSelectorTest extends NamedSelectorTest +class PartialNamedSelectorTest extends TestCase { + use NamedSelectorTestTrait; + protected function getSelector() { return new PartialNamedSelector(); From f04540b0b7f0c7131d7587a4e66f9657ae1a36ec Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Sun, 14 May 2023 12:34:06 +0200 Subject: [PATCH 5/5] chore: fix ci deprecations, add test-runs for php 8.2, allow phpunit 10 --- .../{ElementTest.php => AbstractElement.php} | 8 +------- tests/Element/DocumentElementTest.php | 2 +- tests/Element/NodeElementTest.php | 2 +- ...ctorTestTrait.php => AbstractNamedSelector.php} | 14 +++++++++++++- tests/Selector/ExactNamedSelectorTest.php | 5 +---- tests/Selector/PartialNamedSelectorTest.php | 5 +---- 6 files changed, 18 insertions(+), 18 deletions(-) rename tests/Element/{ElementTest.php => AbstractElement.php} (91%) rename tests/Selector/{NamedSelectorTestTrait.php => AbstractNamedSelector.php} (98%) diff --git a/tests/Element/ElementTest.php b/tests/Element/AbstractElement.php similarity index 91% rename from tests/Element/ElementTest.php rename to tests/Element/AbstractElement.php index a92b66a29..3ddbdc11d 100644 --- a/tests/Element/ElementTest.php +++ b/tests/Element/AbstractElement.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ElementTest extends TestCase +abstract class AbstractElement extends TestCase { /** * Session. @@ -73,10 +73,4 @@ protected function mockNamedFinder($xpath, array $results, $locator, $times = 2) ->with($this->logicalOr('named_exact', 'named_partial'), $locator) ->will($this->returnValue($xpath)); } - - // just to suppress warnings from phpunit 10 of no tests found - public function testDummy() - { - self::assertTrue(true); - } } diff --git a/tests/Element/DocumentElementTest.php b/tests/Element/DocumentElementTest.php index 8250cc3b4..0f33e1de3 100644 --- a/tests/Element/DocumentElementTest.php +++ b/tests/Element/DocumentElementTest.php @@ -4,7 +4,7 @@ use Behat\Mink\Element\DocumentElement; -class DocumentElementTest extends ElementTest +class DocumentElementTest extends AbstractElement { /** * Page. diff --git a/tests/Element/NodeElementTest.php b/tests/Element/NodeElementTest.php index 0766d7a3d..a20201ab5 100644 --- a/tests/Element/NodeElementTest.php +++ b/tests/Element/NodeElementTest.php @@ -4,7 +4,7 @@ use Behat\Mink\Element\NodeElement; -class NodeElementTest extends ElementTest +class NodeElementTest extends AbstractElement { public function testGetXpath() { diff --git a/tests/Selector/NamedSelectorTestTrait.php b/tests/Selector/AbstractNamedSelector.php similarity index 98% rename from tests/Selector/NamedSelectorTestTrait.php rename to tests/Selector/AbstractNamedSelector.php index 35da4a028..9755ad721 100644 --- a/tests/Selector/NamedSelectorTestTrait.php +++ b/tests/Selector/AbstractNamedSelector.php @@ -2,9 +2,11 @@ namespace Behat\Mink\Tests\Selector; +use Behat\Mink\Selector\NamedSelector; use Behat\Mink\Selector\Xpath\Escaper; +use PHPUnit\Framework\TestCase; -trait NamedSelectorTestTrait +abstract class AbstractNamedSelector extends TestCase { public function testRegisterXpath() { @@ -292,4 +294,14 @@ public static function getLateRegisteredReplacements() ), ); } + + /** + * @return NamedSelector + */ + abstract protected function getSelector(); + + /** + * @return bool + */ + abstract protected function allowPartialMatch(); } diff --git a/tests/Selector/ExactNamedSelectorTest.php b/tests/Selector/ExactNamedSelectorTest.php index 11bee640d..8bdf041c5 100644 --- a/tests/Selector/ExactNamedSelectorTest.php +++ b/tests/Selector/ExactNamedSelectorTest.php @@ -3,12 +3,9 @@ namespace Behat\Mink\Tests\Selector; use Behat\Mink\Selector\ExactNamedSelector; -use PHPUnit\Framework\TestCase; -class ExactNamedSelectorTest extends TestCase +class ExactNamedSelectorTest extends AbstractNamedSelector { - use NamedSelectorTestTrait; - protected function getSelector() { return new ExactNamedSelector(); diff --git a/tests/Selector/PartialNamedSelectorTest.php b/tests/Selector/PartialNamedSelectorTest.php index 3298c57ff..72f716196 100644 --- a/tests/Selector/PartialNamedSelectorTest.php +++ b/tests/Selector/PartialNamedSelectorTest.php @@ -3,12 +3,9 @@ namespace Behat\Mink\Tests\Selector; use Behat\Mink\Selector\PartialNamedSelector; -use PHPUnit\Framework\TestCase; -class PartialNamedSelectorTest extends TestCase +class PartialNamedSelectorTest extends AbstractNamedSelector { - use NamedSelectorTestTrait; - protected function getSelector() { return new PartialNamedSelector();