Skip to content

Commit

Permalink
Merge pull request #189 from emodric/phpunit10
Browse files Browse the repository at this point in the history
Add support for PHPUnit 10
  • Loading branch information
lchrusciel authored Jul 12, 2023
2 parents 3b19b5d + 602a891 commit 09ebfd5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1]
symfony: [4.4.*, 5.4.*, 6.0.*]
phpunit: [^8.0, ^9.0]
php-matcher: [^5.0, ^6.0]
php: [8.0, 8.1, 8.2]
symfony: [5.4.*, 6.2.*, 6.3.*]
phpunit: [^9.0, ^10.0]
php-matcher: [^6.0]
exclude:
-
php: 8.0
php-matcher: ^5.0
phpunit: ^10.0
-
php: 8.1
php-matcher: ^5.0
php: 8.0
symfony: 6.2.*
-
php: 7.4
symfony: 6.0.*
php: 8.0
symfony: 6.3.*

steps:
- uses: "actions/checkout@v2"
Expand All @@ -48,7 +48,8 @@ jobs:
-
name: "Restrict Symfony version"
run: |
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer config extra.symfony.require "${{ matrix.symfony }}"
-
Expand Down
29 changes: 17 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.0",
"ext-json": "*",

"coduo/php-matcher": "^5.0 || ^6.0",
"coduo/php-matcher": "^6.0",
"openlss/lib-array2xml": "^1.0",
"doctrine/data-fixtures": "^1.2",
"doctrine/doctrine-bundle": "^1.6 || ^2.0",
"doctrine/doctrine-bundle": "^2.0",
"doctrine/orm": "^2.5",
"nelmio/alice": "^3.6",
"phpspec/php-diff": "^1.1",
"phpunit/phpunit": "^8.0 || ^9.0",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.0",
"symfony/finder": "^4.4 || ^5.4 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/finder": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"theofidry/alice-data-fixtures": "^1.0"
},
"require-dev": {
"phpstan/phpstan-strict-rules": "^0.12",
"phpstan/phpstan-webmozart-assert": "^0.12",
"symfony/serializer": "^4.4 || ^5.4 || ^6.0",
"phpstan/phpstan": "^0.12"
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"symfony/serializer": "^5.4 || ^6.0",
"phpstan/phpstan": "^1.8"
},
"scripts": {
"analyse": [
"vendor/bin/phpstan.phar analyse --ansi --no-progress -l 5 src"
"vendor/bin/phpstan analyse --ansi --no-progress src"
]
},
"conflict": {
Expand All @@ -72,5 +72,10 @@
"branch-alias": {
"dev-master": "5.2-dev"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ includes:
- vendor/phpstan/phpstan-webmozart-assert/extension.neon

parameters:
level: max
level: 5
paths:
- src
- test/src/
5 changes: 2 additions & 3 deletions src/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Doctrine\ORM\EntityManager;
use Fidry\AliceDataFixtures\LoaderInterface;
use Fidry\AliceDataFixtures\ProcessorInterface;
use InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Finder\Finder;
Expand Down Expand Up @@ -51,9 +50,9 @@ abstract class ApiTestCase extends WebTestCase
/** @var EntityManager|null */
private $entityManager;

public function __construct(?string $name = null, array $data = [], $dataName = '')
public function __construct(?string $name = null)
{
parent::__construct($name, $data, $dataName);
parent::__construct($name);

$this->matcherFactory = new MatcherFactory();
}
Expand Down
7 changes: 4 additions & 3 deletions test/src/Controller/SampleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace ApiTestCase\Test\Controller;

use ApiTestCase\Test\Entity\Product;
use ApiTestCase\Test\Entity\Category;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -61,23 +62,23 @@ public function helloWorldAction(Request $request): Response

public function productIndexAction(Request $request): Response
{
$productRepository = $this->objectManager->getRepository('ApiTestCase:Product');
$productRepository = $this->objectManager->getRepository(Product::class);
$products = $productRepository->findAll();

return $this->respond($request, $products);
}

public function categoryIndexAction(Request $request): Response
{
$categoryRepository = $this->objectManager->getRepository('ApiTestCase:Category');
$categoryRepository = $this->objectManager->getRepository(Category::class);
$categories = $categoryRepository->findAll();

return $this->respond($request, $categories);
}

public function showAction(Request $request): Response
{
$productRepository = $this->objectManager->getRepository('ApiTestCase:Product');
$productRepository = $this->objectManager->getRepository(Product::class);
$product = $productRepository->find($request->get('id'));

if (!$product) {
Expand Down

0 comments on commit 09ebfd5

Please sign in to comment.