Skip to content
Draft
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
18 changes: 9 additions & 9 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
php-versions: ['8.2', '8.3', '8.4']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -27,7 +27,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -46,20 +46,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.2'
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -76,20 +76,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: '8.2'
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand Down
2 changes: 1 addition & 1 deletion .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
file that was distributed with this source code.
EOF;

return Config::create()
return (new Config())
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
Expand Down
23 changes: 15 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
}
],
"require": {
"php": "^7.2.5|^8",
"composer/package-versions-deprecated": "1.11.99.5",
"php": "^8.2",
"composer/package-versions-deprecated": "^1.11",
"composer/semver": "^3.3",
"rybakit/phpunit-extras": "^0.2.4",
"symfony/expression-language": "^3.3|^4|^5|^6",
"rybakit/phpunit-extras": "dev-feature/php82-phpunit10-attributes-migration",
"symfony/expression-language": "^7.0",
"tarantool/client": "^0.10"
},
"require-dev": {
"php": "^7.2.5|^8",
"friendsofphp/php-cs-fixer": "^2.19",
"vimeo/psalm": "^3.9|^4"
"friendsofphp/php-cs-fixer": "^3",
"phpunit/phpunit": "^10.5",
"vimeo/psalm": "^5.23|^6"
},
"autoload": {
"psr-4": {
Expand All @@ -38,5 +38,12 @@
"*": "dist"
},
"sort-packages": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [{
"type": "vcs",
"url": "https://github.com/rybakit/phpunit-extras",
"no-api": true
}]
}
67 changes: 24 additions & 43 deletions phpunit-extension.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
verbose="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="date.timezone" value="UTC" />
<ini name="display_errors" value="On" />
<ini name="display_startup_errors" value="On" />
<ini name="error_reporting" value="E_ALL" />
</php>

<testsuites>
<testsuite name="annotation">
<file>tests/Annotation/AnnotationExtensionTest.php</file>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>

<extensions>
<extension class="Tarantool\PhpUnit\Tests\Annotation\AnnotationExtension">
<arguments>
<array>
<element key="bool">
<boolean>true</boolean>
</element>
<element key="int">
<integer>42</integer>
</element>
<element key="str">
<string>foobar</string>
</element>
</array>
</arguments>
</extension>
</extensions>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" colors="true" bootstrap="vendor/autoload.php">
<php>
<ini name="date.timezone" value="UTC"/>
<ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/>
<ini name="error_reporting" value="E_ALL"/>
</php>
<testsuites>
<testsuite name="annotation">
<file>tests/Annotation/AnnotationExtensionTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
<extensions>
<bootstrap class="Tarantool\PhpUnit\Tests\Annotation\AnnotationExtension">
<parameter name="bool" value="true"/>
<parameter name="int" value="42"/>
<parameter name="str" value="foobar"/>
</bootstrap>
</extensions>
</phpunit>
44 changes: 18 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
verbose="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="date.timezone" value="UTC" />
<ini name="display_errors" value="On" />
<ini name="display_startup_errors" value="On" />
<ini name="error_reporting" value="E_ALL" />
</php>

<testsuites>
<testsuite name="unit">
<directory>tests</directory>
<exclude>tests/Annotation/AnnotationExtensionTest.php</exclude>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" colors="true" bootstrap="vendor/autoload.php">
<php>
<ini name="date.timezone" value="UTC"/>
<ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/>
<ini name="error_reporting" value="E_ALL"/>
</php>
<testsuites>
<testsuite name="unit">
<directory>tests</directory>
<exclude>tests/Annotation/AnnotationExtensionTest.php</exclude>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
17 changes: 9 additions & 8 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
</projectFiles>

<issueHandlers>
<InternalMethod>

<UnusedClass>
<errorLevel type="suppress">
<directory name="src" />
</errorLevel>
</UnusedClass>
<PossiblyUnusedMethod>
<errorLevel type="suppress">
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::method" />
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::with" />
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::withConsecutive" />
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::willReturn" />
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::willReturnOnConsecutiveCalls" />
<referencedMethod name="PHPUnit\Framework\TestCase::__construct" />
<directory name="src" />
</errorLevel>
</InternalMethod>
</PossiblyUnusedMethod>
</issueHandlers>
</psalm>
36 changes: 28 additions & 8 deletions src/Annotation/AnnotationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,44 @@
use PHPUnitExtras\Annotation\AnnotationExtension as BaseAnnotationExtension;
use Tarantool\Client\Client;

class AnnotationExtension extends BaseAnnotationExtension

Check warning on line 20 in src/Annotation/AnnotationExtension.php

View workflow job for this annotation

GitHub Actions / Static Analysis

ClassMustBeFinal

src/Annotation/AnnotationExtension.php:20:7: ClassMustBeFinal: Class Tarantool\PhpUnit\Annotation\AnnotationExtension is never extended and is not part of the public API, and thus must be made final. (see https://psalm.dev/361)
{
use Annotations;

/** @var array<string, string|int|bool>|string */
private $clientConfig;
private $clientConfig = 'tcp://127.0.0.1:3301';

/** @var Client|null */
private $client;

/**
* @param array<string, string|int|bool>|string $clientConfig
*/
public function __construct($clientConfig = 'tcp://127.0.0.1:3301')
#[\Override]
public function bootstrap(\PHPUnit\TextUI\Configuration\Configuration $configuration, \PHPUnit\Runner\Extension\Facade $facade, \PHPUnit\Runner\Extension\ParameterCollection $parameters) : void
{
$this->clientConfig = $clientConfig;
$this->parseParameters($parameters);
parent::bootstrap($configuration, $facade, $parameters);
}

protected function parseParameters(\PHPUnit\Runner\Extension\ParameterCollection $parameters) : void
{
if ($parameters->has('dsn')) {
$this->clientConfig = $parameters->get('dsn');
} else {
$closure = \Closure::bind(function () {
/**
* @psalm-suppress InaccessibleProperty
* @var \PHPUnit\Runner\Extension\ParameterCollection $this
*/
return $this->parameters;
}, $parameters, \PHPUnit\Runner\Extension\ParameterCollection::class);
$options = $closure ? $closure() : [];

if ([] !== $options) {
$this->clientConfig = $options;
}
}
}

#[\Override]
protected function getClient() : Client
{
if ($this->client) {
Expand Down Expand Up @@ -71,12 +91,12 @@

private static function resolveEnvValues(string $configValue) : string
{
return preg_replace_callback('/%env\((?P<name>.+?)\)%/', static function (array $matches) : string {
return (string) preg_replace_callback('/%env\((?P<name>.+?)\)%/', static function (array $matches) : string {
if (false !== $value = getenv($matches['name'])) {
return $value;
}

$errorMessage = sprintf('Environment variable "%s" does not exist', $matches['name']);
$errorMessage = \sprintf('Environment variable "%s" does not exist', $matches['name']);
throw new class($errorMessage) extends \RuntimeException implements Exception { };
}, $configValue);
}
Expand Down
39 changes: 39 additions & 0 deletions src/Annotation/Attribute/Lua.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* This file is part of the tarantool/phpunit-extras package.
*
* (c) Eugene Leonovich <gen.work@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Tarantool\PhpUnit\Annotation\Attribute;

use PHPUnitExtras\Annotation\Attribute\AnnotationAttribute;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
final class Lua implements AnnotationAttribute
{
private $code;

public function __construct(string $code)
{
$this->code = $code;
}

#[\Override]
public function getName() : string
{
return 'lua';
}

#[\Override]
public function getValue() : string
{
return $this->code;
}
}
Loading
Loading