Skip to content

Commit

Permalink
Modernize and support Symfony 6 (#23)
Browse files Browse the repository at this point in the history
* migrated to GH actions

* dropped SF 2.x and 3.x

* updated phpunit and composer

* updated project structure to match psr-4, removed useless dependencies in require

* fixed phpunit.xml.dist

* fixing tests

* fixing phpunit.xml.dist
  • Loading branch information
oleg-andreyev authored Mar 19, 2022
1 parent 90f1be5 commit a8099ef
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 52 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
pull_request:

jobs:
unit-tests:
name: "Unit tests"
runs-on: ubuntu-latest

strategy:
matrix:
php-version: ['7.3', '7.4', '8.0', '8.1']
include:
- { php-version: '7.2', dependencies: '--prefer-lowest' }

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug

- name: Install PHP dependencies
run: composer update --no-interaction ${{ matrix.dependencies }}

- name: Run tests
run: vendor/bin/phpunit --coverage-text
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ vendor/
composer.lock
Tests/Functional/app/cache
.idea
/.phpunit.result.cache
/var/
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Installation
This library is available on [Packagist](https://packagist.org/packages/ddeboer/vatin-bundle):

```bash
$ composer require ddeboer/vatin-bundle
composer require ddeboer/vatin-bundle
```

Then add the bundle to your application:
Expand Down Expand Up @@ -55,6 +55,8 @@ format. For more information, see [Symfony’s documentation](http://symfony.com
Additionally, you can check whether the VAT number is in use:

```php
use Ddeboer\VatinBundle\Validator\Constraints\Vatin;

/**
* @Vatin(checkExistence=true)
*/
Expand Down Expand Up @@ -88,7 +90,7 @@ $validator = $container->get('ddeboer_vatin.vatin_validator');
$bool = $validator->isValid('NL123456789B01');
```

Additionally check whether the VAT number is in use:
Additionally, check whether the VAT number is in use:

```php
$bool = $validator->isValid('NL123456789B01', true);
Expand Down
5 changes: 0 additions & 5 deletions Tests/Functional/app/config/config.yml

This file was deleted.

25 changes: 16 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,28 @@
}
],
"require": {
"php": ">=7.2",
"ddeboer/vatin": "^2.0",
"symfony/framework-bundle": "^3.4.26 || ^4.1.12 || ^5.0",
"symfony/validator": "^3.0 || ^4.0 || ^5.0"
"symfony/http-kernel": "^4.0 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0",
"symfony/config": "^4.0 || ^5.0 || ^6.0",
"symfony/validator": "^4.0 || ^5.0 || ^6.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0",
"roave/security-advisories": "dev-latest",
"phpunit/phpunit": "^8.5 || ^9.0",
"doctrine/annotations": "^1.2",
"symfony/yaml": "^2.7 || ^3.0 || ^4.0 || ^5.0"
"symfony/framework-bundle": "^5.0 || ^6.0",
"symfony/yaml": "^5.0 || ^6.0"
},
"autoload": {
"psr-4": {
"Ddeboer\\VatinBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
"Ddeboer\\VatinBundle\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Ddeboer\\VatinBundle\\Tests\\": "tests"
}
}
}
16 changes: 8 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./Tests/Functional/app/autoload.php"
<phpunit bootstrap="./tests/Functional/app/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
syntaxCheck="true">
>
<testsuites>
<testsuite name="ddeboer/vatin-bundle test suite">
<directory suffix="Test.php">./Tests</directory>
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<directory>./src</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./src/Resources</directory>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

<php>
<server name="KERNEL_DIR" value="./Tests/Functional/app"/>
<server name="KERNEL_DIR" value="./tests/Functional/app"/>
<server name="KERNEL_CLASS" value="AppKernel"/>
<ini name="default_socket_timeout" value="3"/>
</php>
</phpunit>
</phpunit>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DdeboerVatinExtension extends Extension
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Tests/Functional/Model.php → tests/Functional/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class Model
* @Vatin(checkExistence=true)
*/
public $vatCheckExistence;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class ValidatorAnnotationTest extends WebTestCase
*/
private $validator;

protected function setUp()
protected function setUp():void
{
static::bootKernel();
$container = static::$kernel->getContainer();
$this->validator = $container->get('validator');
$this->validator = $container->get('test.validator');
}

public function testValid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class AppKernel extends Kernel
{
public function registerBundles()
public function registerBundles(): iterable
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
Expand All @@ -17,4 +17,4 @@ public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.yml');
}
}
}
File renamed without changes.
12 changes: 12 additions & 0 deletions tests/Functional/app/config/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
framework:
secret: ddeboer
test: ~
annotations:
enabled: true
validation:
enable_annotations: true

services:
test.validator:
alias: validator
public: true
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

namespace Ddeboer\VatinBundle\Tests\Validator\Constraints;

use Ddeboer\Vatin\Validator;
use Ddeboer\VatinBundle\Validator\Constraints\Vatin;
use Ddeboer\VatinBundle\Validator\Constraints\VatinValidator;
use Ddeboer\Vatin\Validator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

// BC for Symfony 2 and Symfony 4. To be removed when support for Symfony 2 is dropped
if (!class_exists('Symfony\Component\Validator\Test\ConstraintValidatorTestCase')) {
class_alias('Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest', 'Symfony\Component\Validator\Test\ConstraintValidatorTestCase');
}

class ValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
Expand Down

0 comments on commit a8099ef

Please sign in to comment.