Skip to content

Commit

Permalink
Laravel 10 (#14)
Browse files Browse the repository at this point in the history
* Update dependencies and config files

* Fixes for phpstan and phpunit

* Update CHANGELOG.md

* Update php version in Dockerfile

* Optimize imports in IDEntityProvider.php

---------

Co-authored-by: Ilia Kislitsin <[email protected]>
  • Loading branch information
IlyaKislitsin and Ilia Kislitsin authored Jan 24, 2024
1 parent e228ef0 commit 6ae9cfe
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 81 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,18 @@ on:
jobs: # Docs: <https://git.io/JvxXE>
php:
name: PHP ${{ matrix.php }}, ${{ matrix.setup }} setup, laravel ${{ matrix.laravel }}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
setup: [basic, lowest]
laravel: [default]
coverage: [yes]
php: ['7.3', '7.4', '8.0']
include:
- php: '7.3'
setup: basic
coverage: no
laravel: '^7.0'
php: ['8.1','8.2','8.3']
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 # Action page: <https://github.com/shivammathur/setup-php>
Expand All @@ -39,12 +34,12 @@ jobs: # Docs: <https://git.io/JvxXE>

- name: Get Composer Cache Directory # Docs: <https://git.io/JfAKn#php---composer>
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "output_dir=dir::$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies # Docs: <https://git.io/JfAKn#php---composer>
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.output_dir }}
key: ${{ runner.os }}-composer-${{ matrix.setup }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

Expand Down Expand Up @@ -73,7 +68,7 @@ jobs: # Docs: <https://git.io/JvxXE>
XDEBUG_MODE: coverage
run: composer test-cover

- uses: codecov/codecov-action@v1 # Docs: <https://github.com/codecov/codecov-action>
- uses: codecov/codecov-action@v3 # Docs: <https://github.com/codecov/codecov-action>
if: matrix.coverage == 'yes'
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -83,10 +78,10 @@ jobs: # Docs: <https://git.io/JvxXE>

lint-changelog:
name: Lint changelog file
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Lint changelog file
uses: docker://avtodev/markdown-lint:v1 # Action page: <https://github.com/avto-dev/markdown-lint>
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].

## Unreleased

### Changed

- Minimal PHP version now is `8.1`
- Minimal Laravel version now is `10.0`
- Minimal `fakerphp/faker` version now is `1.21`
- Minimal `avto-dev/extended-laravel-validator` version now is `3.7`
- Minimal `avto-dev/identity-laravel` version now is `5.7`
- Minimal `phpstan/phpstan` version now is `1.10`
- Minimal `phpunit/phpunit` version now is `10.5`
- Version of `composer` in docker container updated up to `2.6.6`

## v3.5.0

### Added
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM php:8.0-alpine
FROM php:8.1-alpine

ENV COMPOSER_HOME="/tmp/composer"

COPY --from=composer:2.0.7 /usr/bin/composer /usr/bin/composer
COPY --from=composer:2.6.6 /usr/bin/composer /usr/bin/composer

RUN set -x \
&& apk add --no-cache binutils git \
&& apk add --no-cache --virtual .build-deps autoconf pkgconf make g++ gcc 1>/dev/null \
&& apk add --no-cache --virtual .build-deps autoconf linux-headers pkgconf make g++ gcc 1>/dev/null \
# install xdebug (for testing with code coverage), but do not enable it
&& pecl install xdebug-3.0.0 1>/dev/null \
&& pecl install xdebug-3.3.0 1>/dev/null \
&& apk del .build-deps \
&& mkdir --parents --mode=777 /src ${COMPOSER_HOME}/cache/repo ${COMPOSER_HOME}/cache/files \
&& ln -s /usr/bin/composer /usr/bin/c \
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.1",
"ext-json": "*",
"ext-mbstring": "*",
"fakerphp/faker": "~1.12"
"fakerphp/faker": "^1.21"
},
"require-dev": {
"avto-dev/extended-laravel-validator": "^3.0",
"avto-dev/identity-laravel": "^4.1 || ^5.0",
"laravel/laravel": "~6.0 || ~7.0 || ~8.0 || ~9.0",
"phpstan/phpstan": "~0.12.34",
"phpunit/phpunit": "^9.3"
"avto-dev/extended-laravel-validator": "^3.7",
"avto-dev/identity-laravel": "^5.7",
"laravel/laravel": "^10.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand Down
56 changes: 25 additions & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
forceCoversAnnotation="true"
stopOnFailure="false">

<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>

<coverage includeUncoveredFiles="false" processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
<report>
<clover outputFile="./coverage/clover.xml"/>
<html outputDirectory="./coverage/html"/>
<text outputFile="php://stdout" showUncoveredFiles="false"/>
<xml outputDirectory="./coverage/xml"/>
</report>
</coverage>
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="true">
<testsuites>
<testsuite name="Unit">
<directory>./tests</directory>
</testsuite>
</testsuites>
<coverage includeUncoveredFiles="false">
<report>
<clover outputFile="./coverage/clover.xml"/>
<html outputDirectory="./coverage/html"/>
<text outputFile="php://stdout"/>
<xml outputDirectory="./coverage/xml"/>
</report>
</coverage>
<source>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</source>
</phpunit>
6 changes: 5 additions & 1 deletion src/Frameworks/Laravel/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ protected function registerFakerGenerator(): void
/** @var ConfigRepository $config */
$config = $app->make(ConfigRepository::class);

return FakerFactory::create($config->get('app.faker_locale', 'en_US'));
/** @var string $locale */
$locale = $config->get('app.faker_locale', 'en_US');

return FakerFactory::create($locale);
});
}

Expand Down Expand Up @@ -107,6 +110,7 @@ protected function userDefinedProviders(): array
/** @var ConfigRepository $config */
$config = $this->app->make('config');

/** @var string[] */
return (array) $config->get(static::getConfigRootKeyName() . '.providers');
}

Expand Down
18 changes: 10 additions & 8 deletions src/Providers/Packages/IDEntityProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace AvtoDev\FakerProviders\Providers\Packages;

use AvtoDev\IDEntity\IDEntity;
use AvtoDev\FakerProviders\Providers\Identifiers;
use AvtoDev\IDEntity\Types\TypedIDEntityInterface;
use AvtoDev\FakerProviders\Providers\AbstractFakerProvider;

Expand All @@ -22,48 +23,49 @@ class IDEntityProvider extends AbstractFakerProvider
*/
public function idEntity(?string $id_type = null): TypedIDEntityInterface
{
/** @var string $id_type */
$id_type = \is_string($id_type) && IDEntity::typeIsSupported($id_type)
? $id_type
: $this->generator->randomElement(...[IDEntity::getSupportedTypes()]);

switch ($id_type) {
case IDEntity::ID_TYPE_VIN:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\VinProvider::class);
$this->lazyLoad(Identifiers\VinProvider::class);

return IDEntity::make($this->generator->vinCode(), $id_type);

case IDEntity::ID_TYPE_GRZ:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\GrzProvider::class);
$this->lazyLoad(Identifiers\GrzProvider::class);

return IDEntity::make($this->generator->grzCode(), $id_type);

case IDEntity::ID_TYPE_STS:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\StsProvider::class);
$this->lazyLoad(Identifiers\StsProvider::class);

return IDEntity::make($this->generator->stsCode(), $id_type);

case IDEntity::ID_TYPE_PTS:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\PtsProvider::class);
$this->lazyLoad(Identifiers\PtsProvider::class);

return IDEntity::make($this->generator->ptsCode(), $id_type);

case IDEntity::ID_TYPE_BODY:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\BodyProvider::class);
$this->lazyLoad(Identifiers\BodyProvider::class);

return IDEntity::make($this->generator->bodyCode(), $id_type);

case IDEntity::ID_TYPE_CHASSIS:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\ChassisProvider::class);
$this->lazyLoad(Identifiers\ChassisProvider::class);

return IDEntity::make($this->generator->chassisCode(), $id_type);

case IDEntity::ID_TYPE_DRIVER_LICENSE_NUMBER:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\DriverLicenseNumberProvider::class);
$this->lazyLoad(Identifiers\DriverLicenseNumberProvider::class);

return IDEntity::make($this->generator->driverLicenseNumber(), $id_type);

case IDEntity::ID_TYPE_CADASTRAL_NUMBER:
$this->lazyLoad(\AvtoDev\FakerProviders\Providers\Identifiers\CadastralNumberProvider::class);
$this->lazyLoad(Identifiers\CadastralNumberProvider::class);

return IDEntity::make($this->generator->cadastralNumber(), $id_type);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/Cars/MarkAndModelProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use AvtoDev\FakerProviders\Tests\Providers\AbstractProviderTestCase;

/**
* @covers \AvtoDev\FakerProviders\Providers\Cars\MarkAndModelProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Cars\MarkAndModelProvider
*/
class MarkAndModelProviderTest extends AbstractProviderTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/Identifiers/BodyProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\BodyProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\BodyProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\BodyProvider
*/
class BodyProviderTest extends AbstractIdentifierTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\CadastralNumberProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\CadastralNumberProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\CadastralNumberProvider
*/
class CadastralNumberProviderTest extends AbstractIdentifierTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/Identifiers/ChassisProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\ChassisProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\ChassisProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\ChassisProvider
*/
class ChassisProviderTest extends AbstractIdentifierTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\DriverLicenseNumberProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\DriverLicenseNumberProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\DriverLicenseNumberProvider
*/
class DriverLicenseNumberProviderTest extends AbstractIdentifierTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/Identifiers/GrzProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\GrzProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\GrzProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\GrzProvider
*/
class GrzProviderTest extends AbstractIdentifierTestCase
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Providers/Identifiers/InnAndKppProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use AvtoDev\FakerProviders\Tests\Providers\AbstractProviderTestCase;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\InnAndKppProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\InnAndKppProvider
*/
class InnAndKppProviderTest extends AbstractProviderTestCase
{
Expand Down Expand Up @@ -120,13 +120,11 @@ protected function isValidInn($inn): bool
$checksum = $this->checksum($inn);

return $checksum === (int) \mb_substr($inn, -1);
break;
case 12:
$inn11 = $this->checksum(\mb_substr($inn, 0, -1));
$inn12 = $this->checksum($inn);

return $inn11 === (int) $inn[10] && $inn12 === (int) $inn[11];
break;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/Identifiers/PtsProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\PtsProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\PtsProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\PtsProvider
*/
class PtsProviderTest extends AbstractIdentifierTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/Identifiers/StsProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\StsProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\StsProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\StsProvider
*/
class StsProviderTest extends AbstractIdentifierTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/Identifiers/VinProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use AvtoDev\FakerProviders\Providers\Identifiers\VinProvider;

/**
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\VinProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Identifiers\VinProvider
*/
class VinProviderTest extends AbstractIdentifierTestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Providers/Packages/IDEntityProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types = 1);

namespace AvtoDev\FakerProviders\Tests\Providers\Cars;
namespace AvtoDev\FakerProviders\Tests\Providers\Packages;

use AvtoDev\IDEntity\IDEntity;
use AvtoDev\IDEntity\Types\TypedIDEntityInterface;
use AvtoDev\FakerProviders\Providers\Packages\IDEntityProvider;
use AvtoDev\FakerProviders\Tests\Providers\AbstractProviderTestCase;

/**
* @covers \AvtoDev\FakerProviders\Providers\Packages\IDEntityProvider<extended>
* @covers \AvtoDev\FakerProviders\Providers\Packages\IDEntityProvider
*/
class IDEntityProviderTest extends AbstractProviderTestCase
{
Expand Down
Loading

0 comments on commit 6ae9cfe

Please sign in to comment.