Skip to content

Commit

Permalink
PhpUnit 11 (#17)
Browse files Browse the repository at this point in the history
* #1118: Added PhpUnit 10 and Symfony 7 requirements for composer.json. Updated CI tests to test PHPUnit 10 version for latest PHP 8.x versions.

Co-authored-by: Yevhen Korniievskyi <[email protected]>
Co-authored-by: AstonVictor <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent 4060948 commit a63b17e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: CI

on: [push, pull_request]
on:
- push
- pull_request

jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
phpunit: [6.5.13, 7.5.18, 8.5.31, 9.5.26]
php: [7.3, 7.4]
include:
- phpunit: 8.5.31
php: 8.0
- phpunit: 9.5.26
php: 8.0
php: 8.2
- phpunit: 9.5.26
php: 8.1
- phpunit: 10.5.38
php: 8.1
php: 8.3
- phpunit: 10.5.38
php: 8.2
- phpunit: 10.5.38
php: 8.3
- phpunit: 11.4.3
php: 8.2
- phpunit: 11.4.3
php: 8.3

steps:
- uses: actions/checkout@v3
Expand All @@ -35,3 +35,4 @@ jobs:
with:
php_version: ${{ matrix.php }}
version: ${{ matrix.phpunit }}
test_suffix: "Test.php"
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
}
],
"require": {
"php": "^7.0 || ^8.0",
"phpunit/phpunit": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10",
"php": "^8.2 || ^8.3",
"phpunit/phpunit": "^9.0 || ^10 || ^11",
"behat/behat": "^3.0.0",
"symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
Expand Down
12 changes: 6 additions & 6 deletions src/TestTraits/BehatProvidingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ trait BehatProvidingTrait {
* @return Behat\Gherkin\Node\FeatureNode
* A Behat feature.
*/
public function parseBehatFeature($featureString, $keywords = NULL) {
$lexer = new Lexer($this->getBehatKeywords($keywords));
public static function parseBehatFeature($featureString, $keywords = NULL) {
$lexer = new Lexer(self::getBehatKeywords($keywords));
$parser = new Parser($lexer);
$feature = $parser->parse($featureString);
return $feature;
Expand All @@ -46,7 +46,7 @@ public function parseBehatFeature($featureString, $keywords = NULL) {
* @return array
* An array of scenarios, each an array of title, scenario, and feature.
*/
public function provideBehatFeature(FeatureNode $feature) {
public static function provideBehatFeature(FeatureNode $feature) {
$scenarios = [];
foreach ($feature->getScenarios() as $scenario) {
if ($scenario instanceof OutlineNode) {
Expand All @@ -69,9 +69,9 @@ public function provideBehatFeature(FeatureNode $feature) {
*
* @return \Behat\Gherkin\Keywords\ArrayKeywords
*/
protected function getBehatKeywords($keywords = NULL) {
protected static function getBehatKeywords($keywords = NULL) {
if (is_null($keywords)) {
$keywords = $this->getBehatDefaultKeywords();
$keywords = self::getBehatDefaultKeywords();
}
return $keywords;
}
Expand All @@ -81,7 +81,7 @@ protected function getBehatKeywords($keywords = NULL) {
*
* @return \Behat\Gherkin\Keywords\ArrayKeywords
*/
public function getBehatDefaultKeywords() {
public static function getBehatDefaultKeywords() {
return new ArrayKeywords([
'en' => [
'feature' => 'Feature',
Expand Down
6 changes: 3 additions & 3 deletions src/TestTraits/BehatTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ trait BehatTestTrait {
* Parses the ::feature property as a Behat feature,
* breaking it down into individual scenarios for testing.
*/
public function providerTestBehatScenario() {
$feature = $this->parseBehatFeature($this->feature);
return $this->provideBehatFeature($feature);
public static function providerTestBehatScenario() {
$feature = self::parseBehatFeature(self::$feature);
return self::provideBehatFeature($feature);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/BehatProvidingTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BehatProvidingTraitTest extends TestCase {

use BehatTestTrait;

protected $feature = <<<'FEATURE'
protected static $feature = <<<'FEATURE'
Feature: BehatProvidingTrait
In order to test a feature
We need to able provide it to phpunit
Expand Down

0 comments on commit a63b17e

Please sign in to comment.