diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index cd18eee..7b8762e 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -14,10 +14,12 @@ jobs:
strategy:
matrix:
php-version: ['8.1', '8.2']
- symfony-require: ['5.0.*', '5.4.*', '6.0.*', '6.4.*']
+ symfony-require: ['6.0.*', '6.4.*']
include:
- php-version: '8.3'
symfony-require: '7.0.*'
+ - php-version: '8.3'
+ symfony-require: '7.1.*'
steps:
- name: 'Setup PHP'
diff --git a/.gitignore b/.gitignore
index 89cf2ae..0342768 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/.phpunit.cache/
/.task/
/docker/
/var/
diff --git a/composer.json b/composer.json
index 3bdea00..ffd7c4d 100644
--- a/composer.json
+++ b/composer.json
@@ -15,24 +15,24 @@
"ext-intl": "*",
"doctrine/collections": "^1.0|^2.0",
"doctrine/inflector": "^2.0",
- "symfony/expression-language": "^5.0|^6.0|^7.0",
- "zenstruck/foundry": "^1.0"
+ "symfony/expression-language": "^6.0|^7.0",
+ "zenstruck/foundry": "^2.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
- "behat/behat": "^3.13",
- "doctrine/doctrine-bundle": "^2.9",
- "doctrine/orm": "^2.15",
- "phpstan/phpstan": "^1.10",
- "phpunit/phpunit": "^9.6",
- "squizlabs/php_codesniffer": "^3.7",
- "symfony/console": "^5.0|^6.0|^7.0",
- "symfony/dotenv": "^5.0|^6.0|^7.0",
- "symfony/framework-bundle": "^5.0|^6.0|^7.0",
- "symfony/phpunit-bridge": "^5.0|^6.0|^7.0",
- "symfony/runtime": "^5.0|^6.0|^7.0",
- "symfony/var-dumper": "^5.0|^6.0|^7.0",
- "symfony/yaml": "^5.0|^6.0|^7.0"
+ "behat/behat": "^3.14",
+ "doctrine/doctrine-bundle": "^2.12",
+ "doctrine/orm": "^3.2.1",
+ "phpstan/phpstan": "^1.11",
+ "phpunit/phpunit": "^10.5|^11.3",
+ "squizlabs/php_codesniffer": "^3.10",
+ "symfony/console": "^6.0|^7.0",
+ "symfony/dotenv": "^6.0|^7.0",
+ "symfony/framework-bundle": "^6.0|^7.0",
+ "symfony/phpunit-bridge": "^6.0|^7.0",
+ "symfony/runtime": "^6.0|^7.0",
+ "symfony/var-dumper": "^6.0|^7.0",
+ "symfony/yaml": "^6.0|^7.0"
},
"autoload": {
"psr-4": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 559a0b9..90b97a8 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -2,8 +2,9 @@
@@ -25,16 +26,12 @@
-
+
-
-
-
-
+
diff --git a/src/ExpressionLanguage/Evaluator/FactoryEvaluator.php b/src/ExpressionLanguage/Evaluator/FactoryEvaluator.php
index 3be277d..fdcb663 100644
--- a/src/ExpressionLanguage/Evaluator/FactoryEvaluator.php
+++ b/src/ExpressionLanguage/Evaluator/FactoryEvaluator.php
@@ -12,7 +12,7 @@
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\MinArgumentGuesser;
use Presta\BehatEvaluator\Foundry\FactoryClassFactory;
use Symfony\Component\PropertyAccess\PropertyAccess;
-use Zenstruck\Foundry\Proxy;
+use Zenstruck\Foundry\Persistence\Proxy;
final class FactoryEvaluator
{
@@ -77,18 +77,18 @@ public function __invoke(
throw new UnexpectedTypeException($value, Proxy::class);
}
- $value->disableAutoRefresh();
+ $value->_disableAutoRefresh();
- return PropertyAccess::createPropertyAccessor()->getValue($value->object(), $accessor);
+ return PropertyAccess::createPropertyAccessor()->getValue($value->_real(), $accessor);
}
switch (true) {
case \is_array($value):
- $value = new ArrayCollection(array_map(static fn (Proxy $proxy): object => $proxy->object(), $value));
+ $value = new ArrayCollection(array_map(static fn (Proxy $proxy): object => $proxy->_real(), $value));
break;
case $value instanceof Proxy:
- $value->disableAutoRefresh();
+ $value->_disableAutoRefresh();
break;
}
diff --git a/src/Foundry/FactoryClassFactory.php b/src/Foundry/FactoryClassFactory.php
index 8707333..9d96235 100644
--- a/src/Foundry/FactoryClassFactory.php
+++ b/src/Foundry/FactoryClassFactory.php
@@ -5,7 +5,7 @@
namespace Presta\BehatEvaluator\Foundry;
use Doctrine\Inflector\Inflector;
-use Zenstruck\Foundry\ModelFactory;
+use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
final class FactoryClassFactory
{
@@ -22,10 +22,10 @@ public function __construct(string $namespace, private readonly Inflector $infle
public function fromName(string $name): string
{
- $name = implode('\\', array_map([$this->inflector, 'classify'], explode('/', $name)));
+ $name = implode('\\', array_map($this->inflector->classify(...), explode('/', $name)));
$factoryClass = "$this->namespace{$name}Factory";
- if (!\is_a($factoryClass, ModelFactory::class, true)) {
+ if (!\is_a($factoryClass, PersistentProxyObjectFactory::class, true)) {
throw new \InvalidArgumentException('You must define a valid factory class.');
}
diff --git a/tests/Application/config/packages/doctrine.yaml b/tests/Application/config/packages/doctrine.yaml
index 046f3ff..3f82441 100644
--- a/tests/Application/config/packages/doctrine.yaml
+++ b/tests/Application/config/packages/doctrine.yaml
@@ -2,12 +2,15 @@ when@test:
doctrine:
dbal:
url: 'pdo-sqlite:///:memory:'
+ use_savepoints: true
logging: false
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
naming_strategy: 'doctrine.orm.naming_strategy.underscore_number_aware'
auto_mapping: true
+ controller_resolver:
+ auto_mapping: false
mappings:
Application:
is_bundle: false
diff --git a/tests/Application/config/packages/zenstruck_foundry.yaml b/tests/Application/config/packages/zenstruck_foundry.yaml
index df12f82..b80bac9 100644
--- a/tests/Application/config/packages/zenstruck_foundry.yaml
+++ b/tests/Application/config/packages/zenstruck_foundry.yaml
@@ -1,3 +1,2 @@
when@test:
zenstruck_foundry:
- auto_refresh_proxies: true
diff --git a/tests/Application/src/Entity/User.php b/tests/Application/src/Entity/User.php
index 4dcd0db..bdb53e4 100644
--- a/tests/Application/src/Entity/User.php
+++ b/tests/Application/src/Entity/User.php
@@ -7,7 +7,7 @@
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
-final class User
+class User
{
#[ORM\Column]
#[ORM\Id]
diff --git a/tests/Application/src/Foundry/Factory/UserFactory.php b/tests/Application/src/Foundry/Factory/UserFactory.php
index c96324e..384a43a 100644
--- a/tests/Application/src/Foundry/Factory/UserFactory.php
+++ b/tests/Application/src/Foundry/Factory/UserFactory.php
@@ -5,19 +5,19 @@
namespace Presta\BehatEvaluator\Tests\Application\Foundry\Factory;
use Presta\BehatEvaluator\Tests\Application\Entity\User;
-use Zenstruck\Foundry\ModelFactory;
+use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
/**
- * @extends ModelFactory
+ * @extends PersistentProxyObjectFactory
*/
-final class UserFactory extends ModelFactory
+final class UserFactory extends PersistentProxyObjectFactory
{
- protected static function getClass(): string
+ public static function class(): string
{
return User::class;
}
- protected function getDefaults(): array
+ protected function defaults(): array|callable
{
return [
'firstname' => self::faker()->firstName(),
diff --git a/tests/Integration/Adapter/FactoryAdapterTest.php b/tests/Integration/Adapter/FactoryAdapterTest.php
index 745efa0..a4417f5 100644
--- a/tests/Integration/Adapter/FactoryAdapterTest.php
+++ b/tests/Integration/Adapter/FactoryAdapterTest.php
@@ -5,6 +5,7 @@
namespace Presta\BehatEvaluator\Tests\Integration\Adapter;
use Doctrine\Common\Collections\ArrayCollection;
+use PHPUnit\Framework\Attributes\DataProvider;
use Presta\BehatEvaluator\Adapter\FactoryAdapter;
use Presta\BehatEvaluator\Exception\UnexpectedTypeException;
use Presta\BehatEvaluator\Tests\Application\Entity\User;
@@ -12,7 +13,7 @@
use Presta\BehatEvaluator\Tests\Integration\KernelTestCase;
use Presta\BehatEvaluator\Tests\Resources\ExpressionLanguageFactory;
use Presta\BehatEvaluator\Tests\Resources\UnsupportedValuesProvider;
-use Zenstruck\Foundry\Proxy;
+use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Test\Factories;
final class FactoryAdapterTest extends KernelTestCase
@@ -20,9 +21,7 @@ final class FactoryAdapterTest extends KernelTestCase
use Factories;
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
if ($expected instanceof \Throwable) {
@@ -61,11 +60,11 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'a string containing only a factory expression with a factory name and an array of attributes'
. ' should find and return the relevant object proxy' => [
- static fn () => UserFactory::find(['firstname' => 'John'])->disableAutoRefresh(),
+ static fn () => UserFactory::find(['firstname' => 'John'])->_disableAutoRefresh(),
'',
];
yield 'a string containing only a factory expression'
@@ -79,7 +78,7 @@ public function values(): iterable
. ' should find and return the relevant object proxy(s)' => [
static fn () => new ArrayCollection(
array_map(
- static fn (Proxy $proxy): object => $proxy->object(),
+ static fn (Proxy $proxy): object => $proxy->_real(),
UserFactory::findBy(['lastname' => 'Doe']),
),
),
@@ -94,7 +93,7 @@ public function values(): iterable
. ' and an integer as third parameter should return the relevant object proxy(s)' => [
static fn () => new ArrayCollection(
array_map(
- static fn (Proxy $proxy): object => $proxy->object(),
+ static fn (Proxy $proxy): object => $proxy->_real(),
UserFactory::all(),
),
),
@@ -105,7 +104,7 @@ public function values(): iterable
. ' should return the relevant object proxy(s)' => [
static fn () => new ArrayCollection(
array_map(
- static fn (Proxy $proxy): object => $proxy->object(),
+ static fn (Proxy $proxy): object => $proxy->_real(),
UserFactory::findBy(['firstname' => 'John']),
),
),
diff --git a/tests/Integration/EvaluatorTest.php b/tests/Integration/EvaluatorTest.php
index a593d63..d457dd7 100644
--- a/tests/Integration/EvaluatorTest.php
+++ b/tests/Integration/EvaluatorTest.php
@@ -4,6 +4,7 @@
namespace Integration;
+use PHPUnit\Framework\Attributes\DataProvider;
use Presta\BehatEvaluator\Evaluator;
use Presta\BehatEvaluator\EvaluatorBuilder;
use Presta\BehatEvaluator\Tests\Application\Foundry\Factory\UserFactory;
@@ -14,9 +15,7 @@ final class EvaluatorTest extends KernelTestCase
{
use Factories;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testRegisteringTheAdapterBeforeCallingTheStaticHelpers(mixed $expected, mixed $value): void
{
UserFactory::createOne(['firstname' => 'John', 'lastname' => 'Doe']);
@@ -30,7 +29,7 @@ public function testRegisteringTheAdapterBeforeCallingTheStaticHelpers(mixed $ex
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'a constant expression should not be necessary' => [
ARRAY_FILTER_USE_KEY,
diff --git a/tests/Resources/FactoryClassFactory/Foo/BarFactory.php b/tests/Resources/FactoryClassFactory/Foo/BarFactory.php
index c58e628..5079729 100644
--- a/tests/Resources/FactoryClassFactory/Foo/BarFactory.php
+++ b/tests/Resources/FactoryClassFactory/Foo/BarFactory.php
@@ -4,22 +4,19 @@
namespace Presta\BehatEvaluator\Tests\Resources\FactoryClassFactory\Foo;
-use Zenstruck\Foundry\ModelFactory;
+use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
/**
- * @extends ModelFactory
+ * @extends PersistentProxyObjectFactory
*/
-final class BarFactory extends ModelFactory
+final class BarFactory extends PersistentProxyObjectFactory
{
- protected static function getClass(): string
+ public static function class(): string
{
return Bar::class;
}
- /**
- * @return array
- */
- protected function getDefaults(): array
+ protected function defaults(): array|callable
{
return [];
}
diff --git a/tests/Resources/FactoryClassFactory/FooBarFactory.php b/tests/Resources/FactoryClassFactory/FooBarFactory.php
index d4e1d7e..a3599a5 100644
--- a/tests/Resources/FactoryClassFactory/FooBarFactory.php
+++ b/tests/Resources/FactoryClassFactory/FooBarFactory.php
@@ -4,22 +4,19 @@
namespace Presta\BehatEvaluator\Tests\Resources\FactoryClassFactory;
-use Zenstruck\Foundry\ModelFactory;
+use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
/**
- * @extends ModelFactory
+ * @extends PersistentProxyObjectFactory
*/
-final class FooBarFactory extends ModelFactory
+final class FooBarFactory extends PersistentProxyObjectFactory
{
- protected static function getClass(): string
+ public static function class(): string
{
return FooBar::class;
}
- /**
- * @return array
- */
- protected function getDefaults(): array
+ protected function defaults(): array|callable
{
return [];
}
diff --git a/tests/Resources/FactoryClassFactory/FooFactory.php b/tests/Resources/FactoryClassFactory/FooFactory.php
index ccdcff5..1e21eae 100644
--- a/tests/Resources/FactoryClassFactory/FooFactory.php
+++ b/tests/Resources/FactoryClassFactory/FooFactory.php
@@ -4,22 +4,19 @@
namespace Presta\BehatEvaluator\Tests\Resources\FactoryClassFactory;
-use Zenstruck\Foundry\ModelFactory;
+use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
/**
- * @extends ModelFactory
+ * @extends PersistentProxyObjectFactory
*/
-final class FooFactory extends ModelFactory
+final class FooFactory extends PersistentProxyObjectFactory
{
- protected static function getClass(): string
+ public static function class(): string
{
return Foo::class;
}
- /**
- * @return array
- */
- protected function getDefaults(): array
+ protected function defaults(): array|callable
{
return [];
}
diff --git a/tests/Unit/Adapter/ConstantAdapterTest.php b/tests/Unit/Adapter/ConstantAdapterTest.php
index b98be54..721d7c7 100644
--- a/tests/Unit/Adapter/ConstantAdapterTest.php
+++ b/tests/Unit/Adapter/ConstantAdapterTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\Adapter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\ConstantAdapter;
use Presta\BehatEvaluator\Tests\Resources\ConstantHolder;
@@ -15,9 +16,7 @@ final class ConstantAdapterTest extends TestCase
{
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
if ($expected instanceof \Throwable) {
@@ -41,7 +40,7 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'a string containing only a PHP constant should return the constant\'s value' => [
ARRAY_FILTER_USE_BOTH,
diff --git a/tests/Unit/Adapter/DateTimeAdapterTest.php b/tests/Unit/Adapter/DateTimeAdapterTest.php
index a56b600..cf35c52 100644
--- a/tests/Unit/Adapter/DateTimeAdapterTest.php
+++ b/tests/Unit/Adapter/DateTimeAdapterTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\Adapter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\DateTimeAdapter;
use Presta\BehatEvaluator\Tests\Resources\ExpressionLanguageFactory;
@@ -13,9 +14,7 @@ final class DateTimeAdapterTest extends TestCase
{
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
$parse = new DateTimeAdapter(ExpressionLanguageFactory::create());
@@ -47,7 +46,7 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
foreach (['datetime' => '\DateTime', 'datetime_immutable' => '\DateTimeImmutable'] as $name => $className) {
yield "a string containing only a $name expression with no parameters"
diff --git a/tests/Unit/Adapter/EnumAdapterTest.php b/tests/Unit/Adapter/EnumAdapterTest.php
index abeff40..7e20796 100644
--- a/tests/Unit/Adapter/EnumAdapterTest.php
+++ b/tests/Unit/Adapter/EnumAdapterTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\Adapter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\EnumAdapter;
use Presta\BehatEvaluator\Tests\Resources\ExpressionLanguageFactory;
@@ -17,9 +18,7 @@ final class EnumAdapterTest extends TestCase
{
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
if ($expected instanceof \Throwable) {
@@ -43,7 +42,7 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'a string containing only a unit enum should return the enum' => [
FooBarEnum::Foo,
diff --git a/tests/Unit/Adapter/JsonAdapterTest.php b/tests/Unit/Adapter/JsonAdapterTest.php
index 5601be9..77addad 100644
--- a/tests/Unit/Adapter/JsonAdapterTest.php
+++ b/tests/Unit/Adapter/JsonAdapterTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\Adapter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\JsonAdapter;
use Presta\BehatEvaluator\Tests\Resources\UnsupportedValuesProvider;
@@ -12,9 +13,7 @@ final class JsonAdapterTest extends TestCase
{
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
$evaluate = new JsonAdapter();
@@ -25,7 +24,7 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'a string should return the same string' => ['foo', 'foo'];
yield 'an empty json array should return an empty php array' => [[], '[]'];
diff --git a/tests/Unit/Adapter/NthAdapterTest.php b/tests/Unit/Adapter/NthAdapterTest.php
index 256b2e0..bf89189 100644
--- a/tests/Unit/Adapter/NthAdapterTest.php
+++ b/tests/Unit/Adapter/NthAdapterTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\Adapter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\NthAdapter;
use Presta\BehatEvaluator\Tests\Resources\UnsupportedValuesProvider;
@@ -12,9 +13,7 @@ final class NthAdapterTest extends TestCase
{
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
$evaluate = new NthAdapter();
@@ -25,7 +24,7 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'a number followed by "st" should return the numerical part as int' => [1, '1st'];
yield 'a number followed by "nd" should return the numerical part as int' => [2, '2nd'];
diff --git a/tests/Unit/Adapter/ScalarAdapterTest.php b/tests/Unit/Adapter/ScalarAdapterTest.php
index 9e3b7c7..7b2d043 100644
--- a/tests/Unit/Adapter/ScalarAdapterTest.php
+++ b/tests/Unit/Adapter/ScalarAdapterTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\Adapter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\ScalarAdapter;
use Presta\BehatEvaluator\Tests\Resources\UnsupportedValuesProvider;
@@ -12,9 +13,7 @@ final class ScalarAdapterTest extends TestCase
{
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
$evaluate = new ScalarAdapter();
@@ -25,7 +24,7 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'the string "null" should return null' => [null, 'null'];
yield 'the string "true" should return true' => [true, 'true'];
diff --git a/tests/Unit/Adapter/UnescapeAdapterTest.php b/tests/Unit/Adapter/UnescapeAdapterTest.php
index 33c05f4..c8d6169 100644
--- a/tests/Unit/Adapter/UnescapeAdapterTest.php
+++ b/tests/Unit/Adapter/UnescapeAdapterTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\Adapter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\UnescapeAdapter;
use Presta\BehatEvaluator\Tests\Resources\UnsupportedValuesProvider;
@@ -12,9 +13,7 @@ final class UnescapeAdapterTest extends TestCase
{
use UnsupportedValuesProvider;
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
$evaluate = new UnescapeAdapter();
@@ -25,7 +24,7 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'a string containing escaped double quotes should return the string with unescaped double quotes' => [
'The double quotes around "foo" should be unescaped',
diff --git a/tests/Unit/EvaluatorTest.php b/tests/Unit/EvaluatorTest.php
index dae39d0..3bb7d0f 100644
--- a/tests/Unit/EvaluatorTest.php
+++ b/tests/Unit/EvaluatorTest.php
@@ -4,15 +4,14 @@
namespace Presta\BehatEvaluator\Tests\Unit;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Adapter\AdapterInterface;
use Presta\BehatEvaluator\Evaluator;
final class EvaluatorTest extends TestCase
{
- /**
- * @dataProvider values
- */
+ #[DataProvider('values')]
public function testInvokingTheEvaluator(mixed $expected, mixed $value): void
{
$adapters = [
@@ -46,7 +45,7 @@ public function __invoke(mixed $value): mixed
/**
* @return iterable
*/
- public function values(): iterable
+ public static function values(): iterable
{
yield 'the string "123" should trigger both adapters and return true' => [true, '123'];
yield 'the value 123 should only trigger the second adapter and return true' => [true, 123];
diff --git a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AccessorArgumentGuesserTest.php b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AccessorArgumentGuesserTest.php
index 49f35a5..044b84e 100644
--- a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AccessorArgumentGuesserTest.php
+++ b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AccessorArgumentGuesserTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\ExpressionLanguage\ArgumentGuesser\Factory;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\AccessorArgumentGuesser;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\ArgumentGuesserInterface;
@@ -14,13 +15,12 @@
final class AccessorArgumentGuesserTest extends TestCase
{
/**
- * @dataProvider arguments
- *
* @param FactoryAttributes|string|null $expected
* @param FactoryAttributes|string|null $method
* @param FactoryAttributes|string|null $min
* @param FactoryAttributes|string|null $attributes
*/
+ #[DataProvider('arguments')]
public function testInvokingTheGuesser(
array|string|null $expected,
array|string|null $method,
@@ -42,7 +42,7 @@ public function testInvokingTheGuesser(
* string|null,
* }>
*/
- public function arguments(): iterable
+ public static function arguments(): iterable
{
yield 'all arguments set not null should return null' => [null, null, null, null, null];
yield 'a non null method and a string as 2nd argument should return the 2nd argument' => [
diff --git a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AttributesArgumentGuesserTest.php b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AttributesArgumentGuesserTest.php
index 5e0bbfa..69e1a78 100644
--- a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AttributesArgumentGuesserTest.php
+++ b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/AttributesArgumentGuesserTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\ExpressionLanguage\ArgumentGuesser\Factory;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\ArgumentGuesserInterface;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\AttributesArgumentGuesser;
@@ -14,13 +15,12 @@
final class AttributesArgumentGuesserTest extends TestCase
{
/**
- * @dataProvider arguments
- *
* @param FactoryAttributes|string|null $expected
* @param FactoryAttributes|string|null $method
* @param FactoryAttributes|string|null $min
* @param FactoryAttributes|string|null $attributes
*/
+ #[DataProvider('arguments')]
public function testInvokingTheGuesser(
array|string|null $expected,
array|string|null $method,
@@ -42,7 +42,7 @@ public function testInvokingTheGuesser(
* string|null,
* }>
*/
- public function arguments(): iterable
+ public static function arguments(): iterable
{
yield 'all arguments set not null should return null' => [null, null, null, null, null];
yield 'an array as 1st argument should return the 1st argument' => [[], [], null, null, null];
diff --git a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MethodArgumentGuesserTest.php b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MethodArgumentGuesserTest.php
index 0d4abd2..a50fd2e 100644
--- a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MethodArgumentGuesserTest.php
+++ b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MethodArgumentGuesserTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\ExpressionLanguage\ArgumentGuesser\Factory;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\ArgumentGuesserInterface;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\MethodArgumentGuesser;
@@ -14,12 +15,11 @@
final class MethodArgumentGuesserTest extends TestCase
{
/**
- * @dataProvider arguments
- *
* @param FactoryAttributes|string|null $method
* @param FactoryAttributes|string|null $min
* @param FactoryAttributes|string|null $attributes
*/
+ #[DataProvider('arguments')]
public function testInvokingTheGuesser(
string $expected,
array|string|null $method,
@@ -41,7 +41,7 @@ public function testInvokingTheGuesser(
* string|null,
* }>
*/
- public function arguments(): iterable
+ public static function arguments(): iterable
{
yield 'all arguments set not null should return the default "find" method' => ['find', null, null, null, null];
yield 'a string as 1st argument should return the 1st argument' => ['count', 'count', null, null, null];
diff --git a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MinArgumentGuesserTest.php b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MinArgumentGuesserTest.php
index f085848..78b6f25 100644
--- a/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MinArgumentGuesserTest.php
+++ b/tests/Unit/ExpressionLanguage/ArgumentGuesser/Factory/MinArgumentGuesserTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\ExpressionLanguage\ArgumentGuesser\Factory;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\ArgumentGuesserInterface;
use Presta\BehatEvaluator\ExpressionLanguage\ArgumentGuesser\Factory\MinArgumentGuesser;
@@ -14,12 +15,11 @@
final class MinArgumentGuesserTest extends TestCase
{
/**
- * @dataProvider arguments
- *
* @param FactoryAttributes|string|null $method
* @param FactoryAttributes|string|null $min
* @param FactoryAttributes|string|null $attributes
*/
+ #[DataProvider('arguments')]
public function testInvokingTheGuesser(
int|null $expected,
array|string|null $method,
@@ -41,7 +41,7 @@ public function testInvokingTheGuesser(
* string|null,
* }>
*/
- public function arguments(): iterable
+ public static function arguments(): iterable
{
yield 'all arguments set not null should return null' => [null, null, null, null, null];
yield 'a non null method and a numeric value as 2nd argument should return the 2nd argument as int' => [
diff --git a/tests/Unit/ExpressionLanguage/ExpressionMatcher/FunctionExpressionMatcherTest.php b/tests/Unit/ExpressionLanguage/ExpressionMatcher/FunctionExpressionMatcherTest.php
index 59b06a2..942eb1c 100644
--- a/tests/Unit/ExpressionLanguage/ExpressionMatcher/FunctionExpressionMatcherTest.php
+++ b/tests/Unit/ExpressionLanguage/ExpressionMatcher/FunctionExpressionMatcherTest.php
@@ -4,6 +4,7 @@
namespace Presta\BehatEvaluator\Tests\Unit\ExpressionLanguage\ExpressionMatcher;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\ExpressionLanguage\ExpressionMatcher\FunctionExpressionMatcher;
@@ -11,9 +12,8 @@ final class FunctionExpressionMatcherTest extends TestCase
{
/**
* @param array $expected
- *
- * @dataProvider strings
*/
+ #[DataProvider('strings')]
public function testMatchingAllExpressions(array $expected, string $name, string $text): void
{
$match = new FunctionExpressionMatcher();
@@ -24,7 +24,7 @@ public function testMatchingAllExpressions(array $expected, string $name, string
/**
* @return iterable, string}>
*/
- public function strings(): iterable
+ public static function strings(): iterable
{
$simpleFunction = 'foobar()';
$functionWithArguments = 'foobar("foo", "bar")';
diff --git a/tests/Unit/Foundry/FactoryClassFactoryTest.php b/tests/Unit/Foundry/FactoryClassFactoryTest.php
index 97e683d..20382e4 100644
--- a/tests/Unit/Foundry/FactoryClassFactoryTest.php
+++ b/tests/Unit/Foundry/FactoryClassFactoryTest.php
@@ -5,14 +5,13 @@
namespace Presta\BehatEvaluator\Tests\Unit\Foundry;
use Doctrine\Inflector\InflectorFactory;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Presta\BehatEvaluator\Foundry\FactoryClassFactory;
final class FactoryClassFactoryTest extends TestCase
{
- /**
- * @dataProvider names
- */
+ #[DataProvider('names')]
public function testCreatingAFactoryClass(\Throwable|string $expected, string $name, string $namespace): void
{
if ($expected instanceof \Throwable) {
@@ -37,7 +36,7 @@ public function testCreatingAFactoryClass(\Throwable|string $expected, string $n
/**
* @return iterable
*/
- public function names(): iterable
+ public static function names(): iterable
{
$namespace = 'Presta\\BehatEvaluator\\Tests\\Resources\\FactoryClassFactory';
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 706e760..5a920c0 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -2,9 +2,12 @@
declare(strict_types=1);
+use Symfony\Component\ErrorHandler\ErrorHandler;
use Symfony\Component\Filesystem\Filesystem;
require dirname(__DIR__) . '/vendor/autoload.php';
+set_exception_handler([new ErrorHandler(), 'handleException']);
+
$filesystem = new Filesystem();
$filesystem->remove(dirname(__DIR__) . '/var/cache/test');