Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests #344

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 33 additions & 64 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: "PHPStan"
runs-on: ubuntu-latest
env:
php-version: 8.1
php-version: 8.2
steps:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
Expand All @@ -19,11 +19,12 @@ jobs:
tools: flex

- name: "Checkout code"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install Composer dependencies"
run: |
composer install --prefer-dist --no-progress --no-interaction --optimize-autoloader
uses: "ramsey/composer-install@v2"
with:
composer-options: "--optimize-autoloader"

- name: "Run PHPStan"
run: |
Expand All @@ -34,7 +35,7 @@ jobs:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
env:
php-version: 8.1
php-version: 8.2
steps:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
Expand All @@ -43,11 +44,12 @@ jobs:
tools: flex, cs2pr

- name: "Checkout code"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install Composer dependencies"
run: |
composer install --prefer-dist --no-progress --no-interaction --optimize-autoloader
uses: "ramsey/composer-install@v2"
with:
composer-options: "--optimize-autoloader"

- name: "Run PHP-CS-Fixer"
run: vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no --format=checkstyle | cs2pr
Expand All @@ -59,63 +61,17 @@ jobs:
max-parallel: 10
fail-fast: true
matrix:
strategy: ['default']
dependencies: ['highest']
php: ['7.4', '8.0', '8.1', '8.2']
include:
- php: '7.4'
sf_version: '5.4.*'
strategy: 'lowest'
- php: '8.0'
sf_version: '5.4.*'
- php: '8.1'
sf_version: '5.4.*'
- php: '8.0'
sf_version: '6.0.*'
- php: '8.1'
sf_version: '6.0.*'
- php: '8.2'
sf_version: '6.2.*'
steps:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: flex
coverage: none

- name: "Checkout code"
uses: actions/checkout@v3

- name: "Install Composer dependencies (default)"
if: matrix.strategy != 'lowest'
env:
SYMFONY_REQUIRE: ${{ matrix.sf_version }}
run: composer update --no-interaction --optimize-autoloader

- name: "Install Composer dependencies (lowest)"
if: matrix.strategy == 'lowest'
env:
SYMFONY_REQUIRE: ${{ matrix.sf_version }}
run: composer update --no-interaction --prefer-stable --prefer-lowest --optimize-autoloader

- name: "Run tests"
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=2'
run: ./vendor/bin/simple-phpunit -v --testsuite main

doctrine:
name: "PHPUnit (Doctrine)"
runs-on: ubuntu-latest
strategy:
max-parallel: 10
fail-fast: true
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
include:
sf_version: '4.4.*'
dependencies: 'lowest'
- php: '7.4'
sf_version: '4.4.*'
- php: '7.4'
sf_version: '5.4.*'
dependencies: 'lowest'
- php: '8.0'
sf_version: '5.4.*'
- php: '8.1'
Expand All @@ -135,14 +91,27 @@ jobs:
coverage: none

- name: "Checkout code"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install Composer dependencies"
env:
SYMFONY_REQUIRE: ${{ matrix.sf_version }}
run: composer update --prefer-source --no-interaction --optimize-autoloader
uses: "ramsey/composer-install@v2"
with:
composer-options: "--optimize-autoloader"
dependency-versions: "${{ matrix.dependencies }}"

# - name: "Install Composer dependencies (default)"
# if: matrix.strategy != 'lowest'
# env:
# SYMFONY_REQUIRE: ${{ matrix.sf_version }}
# run: composer update --no-interaction --optimize-autoloader
#
# - name: "Install Composer dependencies (lowest)"
# if: matrix.strategy == 'lowest'
# env:
# SYMFONY_REQUIRE: ${{ matrix.sf_version }}
# run: composer update --no-interaction --prefer-stable --prefer-lowest --optimize-autoloader

- name: "Run tests"
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=2'
run: ./vendor/bin/simple-phpunit -v --testsuite doctrine
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=3&max[indirect]=1'
run: ./vendor/bin/simple-phpunit -v
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'no_superfluous_phpdoc_tags' => false,
])
->setFinder($finder)
;
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
"require": {
"php": "^7.4 || ^8.0",
"geocoder-php/plugin": "^1.5",
"php-http/curl-client": "^2.3",
"php-http/discovery": "^1.14",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/options-resolver": "^4.4 || ^5.0 || ^6.0",
"willdurand/geocoder": "^4.6"
},
"require-dev": {
"doctrine/annotations": "^1.11.1 || ^2.0",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/orm": "~2.8",
"fakerphp/faker": "^1.20",
"friendsofphp/php-cs-fixer": "^3.13",
Expand Down Expand Up @@ -56,9 +59,10 @@
"nyholm/nsa": "^1.3",
"nyholm/psr7": "^1.5",
"nyholm/symfony-bundle-test": "dev-master",
"php-http/curl-client": "^2.2",
"php-http/mock-client": "^1.6",
"php-http/message": "^1.13",
"phpstan/phpstan": "^1.9.2",
"psr/http-client": "^1.0",
"symfony/cache": "^4.4 || ^5.0 || ^6.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.2 || ^6.0",
Expand All @@ -83,7 +87,8 @@
},
"config": {
"allow-plugins": {
"symfony/flex": true
"symfony/flex": true,
"php-http/discovery": false
},
"sort-packages": true
},
Expand Down
4 changes: 2 additions & 2 deletions doc/doctrine.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You have to indicate which provider to use to reverse geocode the address. Here
- '@bazinga_geocoder.provider.acme'
- '@Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver'
tags:
- doctrine.event_subscriber
- { name: doctrine.event_listener, event: onFlush }
```

It is done!
Expand Down Expand Up @@ -131,5 +131,5 @@ Then update your service configuration to register the `AttributeDriver`:
- '@bazinga_geocoder.provider.acme'
- '@Bazinga\GeocoderBundle\Mapping\Driver\AttributeDriver'
tags:
- doctrine.event_subscriber
- { name: doctrine.event_listener, event: onFlush }
```
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
<testsuites>
<testsuite name="main">
<directory>./tests</directory>
<exclude>./tests/Doctrine</exclude>
</testsuite>

<testsuite name="doctrine">
<directory>./tests/Doctrine</directory>
</testsuite>
</testsuites>

Expand Down
5 changes: 0 additions & 5 deletions src/BazingaGeocoderBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
class BazingaGeocoderBundle extends Bundle
{
/**
* {@inheritdoc}
*
* @return void
*/
public function build(ContainerBuilder $container)
Expand All @@ -37,9 +35,6 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new FactoryValidatorPass());
}

/**
* {@inheritdoc}
*/
public function getPath(): string
{
return \dirname(__DIR__);
Expand Down
4 changes: 0 additions & 4 deletions src/Command/GeocodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public function __construct(ProviderAggregator $geocoder)
}

/**
* {@inheritdoc}
*
* @return void
*/
protected function configure()
Expand All @@ -58,8 +56,6 @@ protected function configure()
}

/**
* {@inheritdoc}
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 0 additions & 5 deletions src/DataCollector/GeocoderDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function reset()
}

/**
* {@inheritdoc}
*
* @return void
*/
public function collect(Request $request, Response $response, \Throwable $exception = null)
Expand Down Expand Up @@ -117,9 +115,6 @@ public function addInstance(ProfilingPlugin $instance)
$this->data['providers'][] = $instance->getName();
}

/**
* {@inheritdoc}
*/
public function getName(): string
{
return 'geocoder';
Expand Down
2 changes: 0 additions & 2 deletions src/DependencyInjection/Compiler/FactoryValidatorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class FactoryValidatorPass implements CompilerPassInterface
private static $factoryServiceIds = [];

/**
* {@inheritdoc}
*
* @return void
*/
public function process(ContainerBuilder $container)
Expand Down
2 changes: 0 additions & 2 deletions src/DependencyInjection/Compiler/ProfilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
class ProfilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*
* @return void
*/
public function process(ContainerBuilder $container)
Expand Down
4 changes: 1 addition & 3 deletions src/Doctrine/ORM/GeocoderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function __construct(Provider $geocoder, DriverInterface $driver)
}

/**
* {@inheritdoc}
*
* @return list<string>
*/
public function getSubscribedEvents(): array
Expand All @@ -52,7 +50,7 @@ public function getSubscribedEvents(): array
*/
public function onFlush(OnFlushEventArgs $args)
{
$em = $args->getEntityManager();
$em = method_exists($args, 'getObjectManager') ? $args->getObjectManager() : $args->getEntityManager();
$uow = $em->getUnitOfWork();

foreach ($uow->getScheduledEntityInsertions() as $entity) {
Expand Down
6 changes: 0 additions & 6 deletions src/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,13 @@ public function __construct(Reader $reader)
$this->reader = $reader;
}

/**
* {@inheritdoc}
*/
public function isGeocodeable($object): bool
{
$reflection = ClassUtils::newReflectionObject($object);

return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class);
}

/**
* {@inheritdoc}
*/
public function loadMetadataFromObject($object)
{
$reflection = ClassUtils::newReflectionObject($object);
Expand Down
5 changes: 0 additions & 5 deletions src/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
*/
final class AttributeDriver implements DriverInterface
{
/**
* {@inheritdoc}
*/
public function isGeocodeable($object): bool
{
if (PHP_VERSION_ID < 80000) {
Expand All @@ -37,8 +34,6 @@ public function isGeocodeable($object): bool
}

/**
* {@inheritdoc}
*
* @throws MappingException
*/
public function loadMetadataFromObject($object): ClassMetadata
Expand Down
8 changes: 1 addition & 7 deletions src/ProviderFactory/AbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class AbstractFactory implements ProviderFactoryInterface

protected ?ClientInterface $httpClient;

public function __construct(?ClientInterface $httpClient = null)
public function __construct(ClientInterface $httpClient = null)
{
$this->httpClient = $httpClient;
}
Expand All @@ -42,9 +42,6 @@ public function __construct(?ClientInterface $httpClient = null)
*/
abstract protected function getProvider(array $config): Provider;

/**
* {@inheritdoc}
*/
public function createProvider(array $options = []): Provider
{
$this->verifyDependencies();
Expand All @@ -56,9 +53,6 @@ public function createProvider(array $options = []): Provider
return $this->getProvider($config);
}

/**
* {@inheritdoc}
*/
public static function validate(array $options, $providerName)
{
static::verifyDependencies();
Expand Down
3 changes: 0 additions & 3 deletions src/ProviderFactory/ChainFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ protected function getProvider(array $config): Provider
return $provider;
}

/**
* {@inheritdoc}
*/
protected static function configureOptionResolver(OptionsResolver $resolver)
{
parent::configureOptionResolver($resolver);
Expand Down
Loading