- What is tarantool/phpunit-extras used for?
- It is a collection of PHPUnit helpers for testing libraries and applications that use the Tarantool PHP client. It provides Tarantool-specific attributes for Lua and SQL setup, requirement checks, request and prepared-statement expectations, and client mocking utilities. It is based on rybakit/phpunit-extras and is intended as a dev-only Composer dependency.
- How do I install tarantool/phpunit-extras in a Laravel project?
- Install it with Composer as a development dependency using composer require --dev tarantool/phpunit-extras. The package is framework-agnostic, so it can live in a Laravel project’s test suite as long as the application uses the Tarantool PHP client. You then either extend Tarantool\PhpUnit\TestCase or register the annotation extension in your PHPUnit configuration.
- Does tarantool/phpunit-extras work with Laravel and which PHP or PHPUnit versions does it need?
- The package is not Laravel-specific and is not constrained by your Laravel version, but v0.3.0 requires PHP 8.2+ and PHPUnit 10. Projects still on PHP 8.0, PHP 8.1, or PHPUnit 9 should stay on the older v0.2.x line unless they upgrade their test platform. In a Laravel app, verify your CI PHP image and phpunit.xml setup match those requirements.
- How do I migrate @lua and @sql annotations to PHP attributes in v0.3.0?
- v0.3.0 replaces annotation-based Lua, SQL, and Tarantool version requirements with PHP attributes, so you need to audit tests using @lua, @sql, and @requires TarantoolVersion. Convert each annotation to its corresponding PHP attribute and update any AnnotationExtension configuration. Plan the migration alongside the PHP 8.2 and PHPUnit 10 upgrade because those platform changes can surface unrelated test-suite issues.
- How do I configure the AnnotationExtension DSN for Tarantool in phpunit.xml?
- Register Tarantool\PhpUnit\Annotation\AnnotationExtension in the PHPUnit extensions section. By default it assumes a Tarantool server at 127.0.0.1:3301, but you can pass a DSN string or an array of options as extension arguments. Revalidate your environment-variable and DSN wiring when moving to PHPUnit 10 configuration.
- What request and prepared-statement expectations does tarantool/phpunit-extras provide?
- The package includes expectation helpers for Tarantool requests and prepared statements, typically used through traits such as RequestExpectations. They let tests assert that the expected requests or prepared statements were made against the client. Advanced mocking requires familiarity with the package’s expectation builders, so start with simple assertions and expand as needed.
- How do I mock a Tarantool client in PHPUnit tests with this package?
- Use the TestDoubleClient trait and related mocking utilities to replace the real Tarantool client in tests. You can adopt the traits incrementally instead of rewriting your whole suite around Tarantool\PhpUnit\TestCase. This is useful for isolating tests from a live Tarantool server, but complex request expectations still require some setup.
- Can I use tarantool/phpunit-extras without extending Tarantool\PhpUnit\TestCase?
- Yes. Extending Tarantool\PhpUnit\TestCase is the easiest way to enable Tarantool-specific features, but you can instead register Tarantool\PhpUnit\Annotation\AnnotationExtension and use traits such as TestDoubleClient or RequestExpectations selectively. This modular approach supports incremental adoption in existing PHPUnit suites.
- Which Tarantool server, tarantool/php client, and ext-msgpack versions are compatible?
- Compatibility depends on the updated package dependencies, so verify the package against your existing tarantool/php client version, ext-msgpack, and Tarantool server version. Version constraints for Tarantool server and client compatibility remain a risk after dependency updates. Test against the exact Tarantool versions used in CI and production-like environments, and remember this is a dev-only dependency.
- Should I upgrade to v0.3.0 or pin v0.2.x, and is the package actively maintained?
- Upgrade to v0.3.0 only after your project is on PHP 8.2+ and PHPUnit 10 and you have audited existing Tarantool annotations and extension configuration. If that platform upgrade is not ready, pin v0.2.x until it is. The v0.3.0 release is a positive maintenance signal, but adoption is still low, so be prepared to maintain edge-case fixes internally; alternatives are limited to rybakit/phpunit-extras for general helpers or plain PHPUnit mocks for non-Tarantool tests.