Skip to content

Commit

Permalink
Drop support for PHP 8.0 and support Symfony 6.4 (#52)
Browse files Browse the repository at this point in the history
* Drop support for PHP 8.0 and support Symfony 6.4

BREAKING CHANGES

- Remove support for PHP 8.0
- Drop support for Symfony 4.4
- Upgrade to only support Symfony 5.4 or 6.4
- Upgrade kununu/data-fixtures to v11.0 (imply same breaking changes as of that version)
- Use Symfony 6.4 components for development
- Rename classes that had "ElasticSearch" to "Elasticsearch"
- Upgrade to PHPUnit 10.5
- Fix tests
- Split test directories for unit and integration tests
- Update documentation
- Upgrade CI workflow to use PHP 8.1
  • Loading branch information
hugo-goncalves-kununu authored Feb 29, 2024
1 parent a8422e2 commit 44e9567
Show file tree
Hide file tree
Showing 101 changed files with 691 additions and 816 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
php-version:
- 8.0
- 8.1
mysql-version:
- 5.7
elasticsearch-version:
Expand All @@ -26,7 +26,7 @@ jobs:
- lowest
- highest
exclude:
- php-version: 8
- php-version: 8.1
dependencies: lowest

services:
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: build-8-highest-coverage
name: build-8.1-highest-coverage
path: tests/.results/

- name: Fix Code Coverage Paths
Expand All @@ -118,4 +118,3 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.php_cs.cache
composer.lock
.idea/
.php_cs.cache
.phpunit.cache
.phpunit.result.cache
tests/App/var/
vendor/
composer.lock
tests/.results/
tests/App/.env.test
tests/App/.env.local
tests/App/.env.test
tests/App/var/
vendor/
phpunit.log
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ Using concepts provided by this bundle, like *Loading Fixtures*, the *RequestBui
```php
<?php

namespace App\Tests\Functional\Controller;
namespace App\Tests\Integration\Controller;

use App\Tests\Functional\Controller\DataFixtures\MySQL\CreateCompanyDataFixtures;
use App\Tests\Integration\Controller\DataFixtures\MySQL\CreateCompanyDataFixtures;
use Kununu\TestingBundle\Test\RequestBuilder;
use Kununu\TestingBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
Expand Down
68 changes: 50 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@
}
],
"require": {
"php": ">=8.0",
"symfony/framework-bundle": "^4.4 || ^5.0",
"kununu/data-fixtures": "^10.2",
"symfony/config": "^4.4 || ^5.0",
"symfony/dependency-injection": "^4.4 || ^5.0",
"symfony/http-kernel": "^4.4 || ^5.0"
"php": ">=8.1",
"symfony/framework-bundle": "^5.4|^6.4",
"kununu/data-fixtures": "^11.0",
"symfony/config": "^5.4|^6.4",
"symfony/dependency-injection": "^5.4|^6.4",
"symfony/http-kernel": "^5.4|^6.4"
},
"require-dev": {
"ext-json": "*",
"ext-pdo": "*",
"doctrine/dbal": "^2.13",
"doctrine/doctrine-bundle": "^2.3.1",
"doctrine/doctrine-migrations-bundle": "^3.1.1",
"doctrine/dbal": "^3.8",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.0",
"elasticsearch/elasticsearch": "^7.10",
"kununu/scripts": ">=3.0.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"phpunit/phpunit": "^8.5 || ^9.0",
"psr/cache": "^1.0",
"symfony/browser-kit": "^5.2",
"symfony/dotenv": "^5.2",
"symfony/phpunit-bridge": "^5.2",
"symfony/http-client": "^4.4 | ^5.2",
"symfony/http-foundation": "^4.4 | ^5.2"
"kununu/scripts": ">=4.0",
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
"phpunit/phpunit": "^10.5",
"psr/cache": "^1.0|^2.0",
"symfony/browser-kit": "^6.4",
"symfony/dotenv": "^6.4",
"symfony/http-client": "^5.4|^6.4",
"symfony/http-foundation": "^5.4|^6.4"
},
"suggest": {
"ext-pdo_mysql": "To run Integration Tests.",
Expand All @@ -67,5 +67,37 @@
"allow-plugins": {
"kununu/scripts": true
}
},
"scripts": {
"unit": "phpunit --log-events-text phpunit.log --no-coverage --no-logging --no-progress --testsuite Unit",
"unit-coverage": "XDEBUG_MODE=coverage phpunit --log-events-text phpunit.log --no-progress --testsuite Unit --log-junit tests/.results/unit-junit.xml --coverage-clover tests/.results/coverage-unit.xml --coverage-html tests/.results/Unit",
"integration": [
"rm -rf tests/App/var/*",
"tests/App/bin/setup_databases.sh test",
"phpunit --log-events-text phpunit.log --no-coverage --no-logging --no-progress --testsuite Integration"
],
"integration-coverage": [
"rm -rf tests/App/var/*",
"tests/App/bin/setup_databases.sh test",
"XDEBUG_MODE=coverage phpunit --log-events-text phpunit.log --no-progress --testsuite Integration --log-junit tests/.results/integration-junit.xml --coverage-clover tests/.results/coverage-integration.xml --coverage-html tests/.results/Integration"
],
"test": [
"rm -rf tests/App/var/*",
"tests/App/bin/setup_databases.sh test",
"phpunit --log-events-text phpunit.log --no-coverage --no-logging --no-progress --testsuite Full"
],
"test-coverage": [
"rm -rf tests/App/var/*",
"tests/App/bin/setup_databases.sh test",
"XDEBUG_MODE=coverage phpunit --log-events-text phpunit.log --no-progress --testsuite Full"
]
},
"scripts-descriptions": {
"unit": "Run all unit tests",
"unit-coverage": "Run all unit tests with coverage report",
"integration": "Run all integration tests",
"integration-coverage": "Run all integration tests with coverage report",
"test": "Run all tests",
"test-coverage": "Run all tests with coverage report"
}
}
6 changes: 3 additions & 3 deletions docs/FixturesTypes/cache-pool-fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use Kununu\TestingBundle\Test\Options\Options;
final class IntegrationTest extends FixturesAwareTestCase
{
public function testIntegration()
public function testIntegration(): void
{
// Start with a clean pool loading data from Fixture1
$this->loadCachePoolFixtures(
Expand Down Expand Up @@ -73,7 +73,7 @@ php bin/console kununu_testing:load_fixtures:cache_pools:MY_CACHE_ID [--append]

### 1. Enable Symfony Command for a Cache Pool

By default Symfony Commands are not created for any cache pool. If you want to enable the creation of a Symfony Command for a specific cache pool you will need to enable it the configuration of the bundle by setting the option `load_command_fixtures_classes_namespace` where you specify the classes names of the fixtures that the command should run.
By default, Symfony Commands are not created for any cache pool. If you want to enable the creation of a Symfony Command for a specific cache pool you will need to enable it the configuration of the bundle by setting the option `load_command_fixtures_classes_namespace` where you specify the classes names of the fixtures that the command should run.

```yaml
kununu_testing:
Expand Down Expand Up @@ -109,7 +109,7 @@ use Kununu\TestingBundle\Test\Options\Options;
final class IntegrationTest extends FixturesAwareTestCase
{
public function testIntegration()
public function testIntegration(): void
{
$this->registerInitializableFixtureForCachePool(
'app.cache.first',
Expand Down
12 changes: 6 additions & 6 deletions docs/FixturesTypes/doctrine-dbal-connection-fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use Kununu\TestingBundle\Test\Options\DbOptions;

final class IntegrationTest extends FixturesAwareTestCase
{
public function testIntegration()
public function testIntegration(): void
{
// Start with an empty database and loading data from Fixture1
$this->loadDbFixtures(
Expand Down Expand Up @@ -67,7 +67,7 @@ use Kununu\TestingBundle\Test\Options\DbOptions;

final class IntegrationTest extends FixturesAwareTestCase
{
public function testIntegration()
public function testIntegration(): void
{
// Start with an empty database and loading data from Fixture1
$this->loadDbFixtures(
Expand Down Expand Up @@ -110,7 +110,7 @@ php bin/console kununu_testing:load_fixtures:non_transactional_connections:CONNE

### 1. Enable Symfony Command for a Doctrine Connection

By default Symfony Commands are not created for any Doctrine Connection. If you want to enable the creation of a Symfony Command for a specific Connection you will need to enable it the configuration of the bundle by setting the option `load_command_fixtures_classes_namespace` where you specify the classes names of the fixtures that the command should run.
By default, Symfony Commands are not created for any Doctrine Connection. If you want to enable the creation of a Symfony Command for a specific Connection you will need to enable it the configuration of the bundle by setting the option `load_command_fixtures_classes_namespace` where you specify the classes names of the fixtures that the command should run.

```yaml
kununu_testing:
Expand All @@ -134,7 +134,7 @@ The fixtures can be loaded for a Connection by running:
php bin/console kununu_testing:load_fixtures:connections:default --append
```

Or for non transactional fixtures:
Or for non-transactional fixtures:

```bash
php bin/console kununu_testing:load_fixtures:non_transactional_connections:default --append
Expand All @@ -156,7 +156,7 @@ use Kununu\TestingBundle\Test\Options\DbOptions;

final class IntegrationTest extends FixturesAwareTestCase
{
public function testIntegration()
public function testIntegration(): void
{
$this->registerInitializableFixtureForDb(
'default',
Expand All @@ -183,7 +183,7 @@ use Kununu\TestingBundle\Test\Options\DbOptions;

final class IntegrationTest extends FixturesAwareTestCase
{
public function testIntegration()
public function testIntegration(): void
{
$this->registerInitializableFixtureForNonTransactionalDb(
'default',
Expand Down
24 changes: 12 additions & 12 deletions docs/FixturesTypes/elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ First you will need to configure the bundle. In this example, we will configure
kununu_testing:
elastic_search:
my_index_alias:
service: 'My\Elasticsearch\Client'
service: 'Elasticsearch\Client' # Your Elasticsearch client service id
index_name: 'my_index_name'
```
In your tests you can extend the classes [FixturesAwareTestCase](/src/Test/FixturesAwareTestCase.php) or [WebTestCase](/src/Test/WebTestCase.php) which expose the following method:
```php
protected function loadElasticSearchFixtures(string $alias, OptionsInterface $options, string ...$classNames): void
protected function loadElasticsearchFixtures(string $alias, OptionsInterface $options, string ...$classNames): void
```
- `$alias` - Alias defined above
Expand All @@ -38,20 +38,20 @@ final class IntegrationTest extends FixturesAwareTestCase
public function testIntegration()
{
// Start with an empty index and loading data from Fixture1
$this->loadElasticSearchFixtures(
$this->loadElasticsearchFixtures(
'my_index_alias',
Options::create(),
Fixture1::class
);
// Start from a empty index
$this->loadElasticSearchFixtures(
$this->loadElasticsearchFixtures(
'my_index_alias',
Options::create()
);
// Do not purge index before loading fixtures
$this->loadElasticSearchFixtures(
$this->loadElasticsearchFixtures(
'my_index_alias',
Options::create()->withAppend(),
Fixture1::class
Expand All @@ -72,15 +72,15 @@ php bin/console kununu_testing:load_fixtures:elastic_search:MY_INDEX_ALIAS [--ap

### 1. Enable Symfony Command for a Elasticsearch Index

By default Symfony Commands are not created for any Elasticsearch Index. If you want to enable the creation of a Symfony Command for a specific Index you will need to enable it the configuration of the bundle by setting the option `load_command_fixtures_classes_namespace` where you specify the classes names of the fixtures that the command should run.
By default, Symfony Commands are not created for any Elasticsearch Index. If you want to enable the creation of a Symfony Command for a specific Index you will need to enable it the configuration of the bundle by setting the option `load_command_fixtures_classes_namespace` where you specify the classes names of the fixtures that the command should run.

```yaml
kununu_testing:
elastic_search:
my_index_alias:
load_command_fixtures_classes_namespace:
- 'Kununu\TestingBundle\Tests\App\Fixtures\ElasticSearch\ElasticSearchFixture1'
- 'Kununu\TestingBundle\Tests\App\Fixtures\ElasticSearch\ElasticSearchFixture2'
- 'Kununu\TestingBundle\Tests\App\Fixtures\Elasticsearch\ElasticsearchFixture1'
- 'Kununu\TestingBundle\Tests\App\Fixtures\Elasticsearch\ElasticsearchFixture2'
```

### 2. Run Symfony Command
Expand Down Expand Up @@ -109,15 +109,15 @@ final class IntegrationTest extends FixturesAwareTestCase
{
public function testIntegration()
{
$this->registerInitializableFixtureForElasticSearch(
$this->registerInitializableFixtureForElasticsearch(
'my_index_alias',
YourElasticsearchFixtureClass::class,
$yourArg1,
// ...,
$yourArgN
);
$this->loadElasticSearchFixtures(
$this->loadElasticsearchFixtures(
'my_index_alias',
Options::create(),
YourElasticsearchFixtureClass::class
Expand All @@ -137,7 +137,7 @@ kununu_testing:
elastic_search:
my_index_alias: # Alias to be used to load fixtures for the configured index using the defined service
load_command_fixtures_classes_namespace:
- 'Kununu\TestingBundle\Tests\App\Fixtures\ElasticSearch\ElasticSearchFixture2' # FQDN for a fixtures class
service: 'Kununu\TestingBundle\Tests\App\ElasticSearch' # Service Id of an instance of Elasticsearch\Client
- 'Kununu\TestingBundle\Tests\App\Fixtures\Elasticsearch\ElasticsearchFixture2' # FQDN for a fixtures class
service: 'Kununu\TestingBundle\Tests\App\Elasticsearch' # Service Id of an instance of Elasticsearch\Client
index_name: 'my_index_name' # name of your index
```
5 changes: 2 additions & 3 deletions docs/FixturesTypes/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If this method returns `true` then it will clear any previous loaded fixtures cl

## Options

The class [Options](/src/Test/Options/Options.php) is provided and it implements the `OptionsInterface` and also provides a builder pattern.
The class [Options](/src/Test/Options/Options.php) is provided, and it implements the `OptionsInterface` and also provides a builder pattern.

```php
use Kununu\TestingBundle\Test\Options\Options;
Expand Down Expand Up @@ -67,11 +67,10 @@ If this method returns `true` then it will use a transactional executor, otherwi

## DbOptions

The class [DbOptions](/src/Test/Options/DbOptions.php) is provided and it implements the `DbOptionsInterface` and also provides a builder pattern.
The class [DbOptions](/src/Test/Options/DbOptions.php) is provided, and it implements the `DbOptionsInterface` and also provides a builder pattern.

It extends the `Options` class so all the methods available there are still in this class.


```php
use Kununu\TestingBundle\Test\Options\DbOptions;

Expand Down
5 changes: 2 additions & 3 deletions docs/FixturesTypes/symfony-http-client.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Symfony Http Client Fixtures

This bundle integrates seamless with *Symfony Http Client Fixtures*
from [kununu/data-fixtures](https://github.com/kununu/data-fixtures).
This bundle integrates seamless with *Symfony Http Client Fixtures* from [kununu/data-fixtures](https://github.com/kununu/data-fixtures).

In the rest of the documentation we will assume that you are using the [Symfony Http Client](https://github.com/symfony/http-client) and [Symfony Http Foundation](https://github.com/symfony/http-foundation) and have configured an Http client service called *app.my.http_client*.

Expand All @@ -19,7 +18,7 @@ protected function loadHttpClientFixtures(string $httpClientServiceId, OptionsIn
- `$options` - [Options](options.md) for the fixtures load process
- `...$classNames` - Classes names of fixtures to load

**Example of loading fixtures in a Integration Test**
**Example of loading fixtures in an Integration Test**

```php
use Kununu\TestingBundle\Test\FixturesAwareTestCase;
Expand Down
Loading

0 comments on commit 44e9567

Please sign in to comment.