Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a3e92a4
Migrate to PHP 8.2, PHPUnit 10 and PHP Attributes
rybakit Jun 10, 2026
f030d87
Fix Psalm and response shape for evaluate
rybakit Jul 25, 2026
bb367f4
Restore library API methods incorrectly removed by Psalm
rybakit Jul 25, 2026
ee84ea0
Fix composer.json and phpunit xml
rybakit Jul 25, 2026
d5295a9
Use ^8.2 for PHP constraint
rybakit Jul 25, 2026
5586fdc
Drop unsupported PHP versions from CI matrix
rybakit Jul 25, 2026
9785da3
Update GitHub Actions to v4
rybakit Jul 25, 2026
61e5869
Fix composer repositories for CI
rybakit Jul 25, 2026
5215780
Rename .php_cs.dist to .php-cs-fixer.dist.php
rybakit Jul 25, 2026
043ed12
Remove accidental .bak files
rybakit Jul 25, 2026
e1b9eb6
Use no-api for composer VCS repositories to prevent GitHub rate limits
rybakit Jul 25, 2026
e73bed0
Fix code style issues for php-cs-fixer 3.0
rybakit Jul 25, 2026
84c984e
Fix strict comparison in mock builder causing tests to fail
rybakit Jul 26, 2026
042b8c1
Revert evaluate back to call for box.info
rybakit Jul 26, 2026
ee57f20
feat: migrate Tarantool integration to attributes
rybakit Sep 28, 2026
b768a39
style: apply php-cs-fixer formatting
rybakit Sep 28, 2026
a5771b5
fix: require expression language for expectations
rybakit Sep 28, 2026
75fc1db
fix: clear CI deprecations and Psalm findings
rybakit Sep 28, 2026
c043b2b
refactor: rename Lua requirement attribute
rybakit Sep 28, 2026
b544f5e
style: import PHPUnit extension types
rybakit Sep 28, 2026
53daaa7
refactor: rename Lua condition requirement
rybakit Sep 28, 2026
fafb986
refactor: rename Tarantool version requirement
rybakit Sep 28, 2026
152d2f3
docs: update PHPUnit 10 extension configuration
rybakit Sep 28, 2026
cfbd121
Update composer.json
rybakit Sep 29, 2026
5772b38
fix(ci): upgrade setup-php to patched version
rybakit Sep 29, 2026
c4908fb
fix(ci): use valid setup-php release tag
rybakit Sep 29, 2026
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
36 changes: 18 additions & 18 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ jobs:
tests:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
operating-system: [ubuntu-24.04]
php-versions: ['8.2', '8.3', '8.4', '8.5']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v7

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

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

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -43,23 +43,23 @@ jobs:

static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
uses: shivammathur/setup-php@2.37.1
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)"
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -73,23 +73,23 @@ jobs:

coding-standard:
name: Coding Standard
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
uses: shivammathur/setup-php@2.37.1
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)"
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v2
uses: actions/cache@v6
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
109 changes: 46 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ It is based on [rybakit/phpunit-extras](https://github.com/rybakit/phpunit-extra
## Table of contents

* [Installation](#installation)
* [Annotations](#annotations)
* [Attributes](#attributes)
* [Processors](#processors)
* [Lua](#lua)
* [Sql](#sql)
* [Requirements](#requirements)
* [LuaCondition](#luacondition)
* [TarantoolVersion](#tarantoolversion)
* [RequiresIfLua](#requiresiflua)
* [RequiresTarantool](#requirestarantool)
* [Expectations](#expectations)
* [Requests](#requests)
* [Prepared statements](#prepared-statements)
Expand All @@ -32,10 +32,10 @@ composer require --dev tarantool/phpunit-extras
```


## Annotations
## Attributes

Besides the annotations provided by the package `rybakit/phpunit-extras`, the library is shipped
with annotations specific to Tarantool. The easiest way to enable them is by inheriting your test classes
Besides the attributes provided by the package `rybakit/phpunit-extras`, the library is shipped
with attributes specific to Tarantool. The easiest way to enable them is by inheriting your test classes
from `Tarantool\PhpUnit\TestCase`:

```php
Expand All @@ -53,61 +53,56 @@ final class MyTest extends TestCase
}
```

Another option is to register an extension called `AnnotationExtension`:
Another option is to register an extension called `AttributeExtension`:

```xml
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
>
<!-- ... -->

<extensions>
<extension class="Tarantool\PhpUnit\Annotation\AnnotationExtension" />
<bootstrap class="Tarantool\PhpUnit\Attribute\AttributeExtension" />
</extensions>
</phpunit>
```

By default, the extension assumes that the Tarantool server you are going to connect to is available on `127.0.0.1:3301`.
You can customize the default settings by specifying either a [DSN string](https://github.com/tarantool-php/client#dsn-string) or an [array of options](https://github.com/tarantool-php/client#array-of-options)
as extension configuration values:
as extension configuration values. PHPUnit 10 passes extension parameters as strings, so use the DSN form for options that require numeric or Boolean values (such as `socket_timeout`):

```xml
<extension class="Tarantool\PhpUnit\Annotation\AnnotationExtension">
<arguments>
<string>tcp://127.0.0.1:3301/?socket_timeout=10</string>
</arguments>
</extension>
<extensions>
<bootstrap class="Tarantool\PhpUnit\Attribute\AttributeExtension">
<parameter name="dsn" value="tcp://127.0.0.1:3301/?socket_timeout=10" />
</bootstrap>
</extensions>
```
or
```xml
<extension class="Tarantool\PhpUnit\Annotation\AnnotationExtension">
<arguments>
<array>
<element key="uri">
<string>tcp://127.0.0.1:3301</string>
</element>
<element key="socket_timeout">
<integer>10</integer>
</element>
</array>
</arguments>
</extension>
<extensions>
<bootstrap class="Tarantool\PhpUnit\Attribute\AttributeExtension">
<parameter name="uri" value="tcp://127.0.0.1:3301" />
<parameter name="username" value="tester" />
<parameter name="password" value="secret" />
</bootstrap>
</extensions>
```

On top of that, the configuration values can resolve environment variables,
which might be useful if you need to share the same settings with a Tarantool
instance file or any other script:

```xml
<extension class="Tarantool\PhpUnit\Annotation\AnnotationExtension">
<arguments>
<string>tcp://%env(TARANTOOL_HOST)%:%env(TARANTOOL_PORT)%</string>
</arguments>
</extension>
<extensions>
<bootstrap class="Tarantool\PhpUnit\Attribute\AttributeExtension">
<parameter name="dsn" value="tcp://%env(TARANTOOL_HOST)%:%env(TARANTOOL_PORT)%" />
</bootstrap>
</extensions>
```

Once the annotations are configured, you can start using them:
Once the attributes are configured, you can start using them:

### Processors

Expand All @@ -118,10 +113,10 @@ Allows executing Lua code before running a test.
*Example:*

```php
/**
* @lua tube:put('kick_me')
* @lua tube:bury(0)
*/
use Tarantool\PhpUnit\Attribute\Lua;

#[Lua("tube:put('kick_me')")]
#[Lua('tube:bury(0)')]
public function testKickReleasesBuriedTask() : void
{
// ...
Expand All @@ -135,11 +130,11 @@ Allows executing SQL statements before running a test (requires Tarantool 2.0+).
*Example:*

```php
/**
* @sql DROP TABLE IF EXISTS foobar
* @sql CREATE TABLE foobar (id INTEGER PRIMARY KEY, name VARCHAR(50))
* @sql INSERT INTO foobar VALUES (1, 'A'), (2, 'B')
*/
use Tarantool\PhpUnit\Attribute\Sql;

#[Sql('DROP TABLE IF EXISTS foobar')]
#[Sql('CREATE TABLE foobar (id INTEGER PRIMARY KEY, name VARCHAR(50))')]
#[Sql("INSERT INTO foobar VALUES (1, 'A'), (2, 'B')")]
public function testExecuteQueryFetchesAllRows() : void
{
// ...
Expand All @@ -151,50 +146,38 @@ public function testExecuteQueryFetchesAllRows() : void

Requirements allow skipping tests based on preconditions.

#### LuaCondition

*Format:*

```
@requires luaCondition <condition>
```
#### RequiresIfLua
where `<condition>` is an arbitrary lua expression that should be evaluated to a Boolean value.

*Example:*

```php
/**
* @requires luaCondition box.session.user() ~= 'guest'
*/
use Tarantool\PhpUnit\Attribute\RequiresIfLua;

#[RequiresIfLua("box.session.user() ~= 'guest'")]
public function testChangeUserPassword() : void
{
// ...
}
```

#### TarantoolVersion

*Format:*

```
@requires Tarantool <version-constraint>
```
#### RequiresTarantool
where `<version-constraint>` is a composer-like version constraint. For details on supported formats,
please see the Composer [documentation](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints).

*Example:*

```php
/**
* @requires Tarantool ^2.3.2
*/
use Tarantool\PhpUnit\Attribute\RequiresTarantool;

#[RequiresTarantool('^2.3.2')]
public function testPrepareCreatesPreparedStatement() : void
{
// ...
}
```

> *If you're interested in how to create and register your own annotations and requirements,
> *If you're interested in how to create and register your own attributes and requirements,
> please refer to the `rybakit/phpunit-extras` [README](https://github.com/rybakit/phpunit-extras).*


Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tarantool/phpunit-extras",
"description": "A collection of helpers for PHPUnit to ease testing Tarantool libraries.",
"keywords": ["tarantool", "phpunit", "annotations", "assertions", "expectations", "extensions", "mocking"],
"keywords": ["tarantool", "phpunit", "attributes", "assertions", "expectations", "extensions", "mocking"],
"type": "library",
"license": "MIT",
"authors": [
Expand All @@ -11,17 +11,16 @@
}
],
"require": {
"php": "^7.2.5|^8",
"composer/package-versions-deprecated": "1.11.99.5",
"php": "^8.2",
"composer/semver": "^3.3",
"rybakit/phpunit-extras": "^0.2.4",
"symfony/expression-language": "^3.3|^4|^5|^6",
"rybakit/phpunit-extras": "^0.3.0",
"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 +37,6 @@
"*": "dist"
},
"sort-packages": true
}
},
"prefer-stable": true
}
Loading