Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Ben87 committed Aug 17, 2024
1 parent bb20afd commit ccd4b18
Show file tree
Hide file tree
Showing 30 changed files with 113 additions and 130 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:

strategy:
matrix:
php-version: ['8.1', '8.2']
symfony-require: ['5.0.*', '5.4.*', '6.0.*', '6.4.*']
php-version: ['8.3']
symfony-require: ['7.0.*', '7.1.*']
include:
- php-version: '8.3'
symfony-require: '7.0.*'
- php-version: ['8.1', '8.2']
symfony-require: ['6.0.*', '6.4.*']

steps:
- name: 'Setup PHP'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.phpunit.cache/
/.task/
/docker/
/var/
Expand Down
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "^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": {
Expand Down
13 changes: 5 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
testdox="true"
>
<php>
Expand All @@ -25,16 +26,12 @@
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
<directory>src</directory>
</include>
<exclude>
<directory>src/ExpressionLanguage/Compiler</directory>
</exclude>
</coverage>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</source>
</phpunit>
10 changes: 5 additions & 5 deletions src/ExpressionLanguage/Evaluator/FactoryEvaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Foundry/FactoryClassFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Presta\BehatEvaluator\Foundry;

use Doctrine\Inflector\Inflector;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;

final class FactoryClassFactory
{
Expand All @@ -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.');
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Application/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/Application/config/packages/zenstruck_foundry.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
when@test:
zenstruck_foundry:
auto_refresh_proxies: true
2 changes: 1 addition & 1 deletion tests/Application/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
final class User
class User
{
#[ORM\Column]
#[ORM\Id]
Expand Down
10 changes: 5 additions & 5 deletions tests/Application/src/Foundry/Factory/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<User>
* @extends PersistentProxyObjectFactory<User>
*/
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(),
Expand Down
17 changes: 8 additions & 9 deletions tests/Integration/Adapter/FactoryAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
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;
use Presta\BehatEvaluator\Tests\Application\Foundry\Factory\UserFactory;
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
{
use Factories;
use UnsupportedValuesProvider;

/**
* @dataProvider values
*/
#[DataProvider('values')]
public function testInvokingTheAdapter(mixed $expected, mixed $value): void
{
if ($expected instanceof \Throwable) {
Expand Down Expand Up @@ -61,11 +60,11 @@ public function testInvokingTheAdapter(mixed $expected, mixed $value): void
/**
* @return iterable<string, array{mixed, mixed}>
*/
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(),
'<factory("user", {"firstname": "John"})>',
];
yield 'a string containing only a factory expression'
Expand All @@ -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']),
),
),
Expand All @@ -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(),
),
),
Expand 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']),
),
),
Expand Down
7 changes: 3 additions & 4 deletions tests/Integration/EvaluatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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']);
Expand All @@ -30,7 +29,7 @@ public function testRegisteringTheAdapterBeforeCallingTheStaticHelpers(mixed $ex
/**
* @return iterable<string, array{mixed, mixed}>
*/
public function values(): iterable
public static function values(): iterable
{
yield 'a constant expression should not be necessary' => [
ARRAY_FILTER_USE_KEY,
Expand Down
13 changes: 5 additions & 8 deletions tests/Resources/FactoryClassFactory/Foo/BarFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@

namespace Presta\BehatEvaluator\Tests\Resources\FactoryClassFactory\Foo;

use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;

/**
* @extends ModelFactory<Bar>
* @extends PersistentProxyObjectFactory<Bar>
*/
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<mixed>
*/
protected function getDefaults(): array
protected function defaults(): array|callable
{
return [];
}
Expand Down
13 changes: 5 additions & 8 deletions tests/Resources/FactoryClassFactory/FooBarFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@

namespace Presta\BehatEvaluator\Tests\Resources\FactoryClassFactory;

use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;

/**
* @extends ModelFactory<FooBar>
* @extends PersistentProxyObjectFactory<FooBar>
*/
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<mixed>
*/
protected function getDefaults(): array
protected function defaults(): array|callable
{
return [];
}
Expand Down
13 changes: 5 additions & 8 deletions tests/Resources/FactoryClassFactory/FooFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@

namespace Presta\BehatEvaluator\Tests\Resources\FactoryClassFactory;

use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;

/**
* @extends ModelFactory<Foo>
* @extends PersistentProxyObjectFactory<Foo>
*/
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<mixed>
*/
protected function getDefaults(): array
protected function defaults(): array|callable
{
return [];
}
Expand Down
Loading

0 comments on commit ccd4b18

Please sign in to comment.