Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/Autocomplete/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"symfony/uid": "^6.3|^7.0",
"twig/twig": "^2.14.7|^3.0.4",
"zenstruck/browser": "^1.1",
"zenstruck/foundry": "1.37.*"
"zenstruck/foundry": "^2.0"
},
"conflict": {
"doctrine/orm": "2.9.0 || 2.9.1"
Expand Down
33 changes: 5 additions & 28 deletions src/Autocomplete/tests/Fixtures/Factory/CategoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,15 @@

namespace Symfony\UX\Autocomplete\Tests\Fixtures\Factory;

use Doctrine\ORM\EntityRepository;
use Symfony\UX\Autocomplete\Tests\Fixtures\Entity\Category;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

/**
* @extends ModelFactory<Category>
*
* @method static Category|Proxy createOne(array $attributes = [])
* @method static Category[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static Category|Proxy find(object|array|mixed $criteria)
* @method static Category|Proxy findOrCreate(array $attributes)
* @method static Category|Proxy first(string $sortedField = 'id')
* @method static Category|Proxy last(string $sortedField = 'id')
* @method static Category|Proxy random(array $attributes = [])
* @method static Category|Proxy randomOrCreate(array $attributes = []))
* @method static Category[]|Proxy[] all()
* @method static Category[]|Proxy[] findBy(array $attributes)
* @method static Category[]|Proxy[] randomSet(int $number, array $attributes = []))
* @method static Category[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
* @method static EntityRepository|RepositoryProxy repository()
* @method Category|Proxy create(array|callable $attributes = [])
* @extends PersistentObjectFactory<Category>
*/
final class CategoryFactory extends ModelFactory
final class CategoryFactory extends PersistentObjectFactory
{
protected function getDefaults(): array
protected function defaults(): array
{
$name = self::faker()->name();
return [
Expand All @@ -46,12 +28,7 @@ protected function getDefaults(): array
];
}

protected function initialize(): self
{
return $this;
}

protected static function getClass(): string
public static function class(): string
{
return Category::class;
}
Expand Down
41 changes: 9 additions & 32 deletions src/Autocomplete/tests/Fixtures/Factory/CategoryTagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,23 @@

namespace Symfony\UX\Autocomplete\Tests\Fixtures\Factory;

use Doctrine\ORM\EntityRepository;
use Symfony\UX\Autocomplete\Tests\Fixtures\Entity\CategoryTag;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

/**
* @extends ModelFactory<CategoryTag>
*
* @method static CategoryTag|Proxy createOne(array $attributes = [])
* @method static CategoryTag[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static CategoryTag|Proxy find(object|array|mixed $criteria)
* @method static CategoryTag|Proxy findOrCreate(array $attributes)
* @method static CategoryTag|Proxy first(string $sortedField = 'id')
* @method static CategoryTag|Proxy last(string $sortedField = 'id')
* @method static CategoryTag|Proxy random(array $attributes = [])
* @method static CategoryTag|Proxy randomOrCreate(array $attributes = [])
* @method static CategoryTag[]|Proxy[] all()
* @method static CategoryTag[]|Proxy[] findBy(array $attributes)
* @method static CategoryTag[]|Proxy[] randomSet(int $number, array $attributes = [])
* @method static CategoryTag[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
* @method static EntityRepository|RepositoryProxy repository()
* @method CategoryTag|Proxy create(array|callable $attributes = [])
* @extends PersistentObjectFactory<CategoryTag>
*/
final class CategoryTagFactory extends ModelFactory
final class CategoryTagFactory extends PersistentObjectFactory
{
protected function getDefaults(): array
{
return [
'name' => self::faker()->word(),
];
}

protected function initialize(): self
public static function class(): string
{
return $this;
return CategoryTag::class;
}

protected static function getClass(): string
protected function defaults(): array
{
return CategoryTag::class;
return [
'name' => self::faker()->word(),
];
}
}
41 changes: 9 additions & 32 deletions src/Autocomplete/tests/Fixtures/Factory/IngredientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,25 @@

namespace Symfony\UX\Autocomplete\Tests\Fixtures\Factory;

use Doctrine\ORM\EntityRepository;
use Symfony\Component\Uid\UuidV4;
use Symfony\UX\Autocomplete\Tests\Fixtures\Entity\Ingredient;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

/**
* @extends ModelFactory<Ingredient>
*
* @method static Ingredient|Proxy createOne(array $attributes = [])
* @method static Ingredient[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static Ingredient|Proxy find(object|array|mixed $criteria)
* @method static Ingredient|Proxy findOrCreate(array $attributes)
* @method static Ingredient|Proxy first(string $sortedField = 'id')
* @method static Ingredient|Proxy last(string $sortedField = 'id')
* @method static Ingredient|Proxy random(array $attributes = [])
* @method static Ingredient|Proxy randomOrCreate(array $attributes = []))
* @method static Ingredient[]|Proxy[] all()
* @method static Ingredient[]|Proxy[] findBy(array $attributes)
* @method static Ingredient[]|Proxy[] randomSet(int $number, array $attributes = []))
* @method static Ingredient[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
* @method static EntityRepository|RepositoryProxy repository()
* @method Ingredient|Proxy create(array|callable $attributes = [])
* @extends PersistentObjectFactory<Ingredient>
*/
final class IngredientFactory extends ModelFactory
final class IngredientFactory extends PersistentObjectFactory
{
protected function getDefaults(): array
public static function class(): string
{
return Ingredient::class;
}

protected function defaults(): array
{
return [
'id' => new UuidV4(),
'name' => self::faker()->text(),
];
}

protected function initialize(): self
{
return $this;
}

protected static function getClass(): string
{
return Ingredient::class;
}
}
42 changes: 10 additions & 32 deletions src/Autocomplete/tests/Fixtures/Factory/ProductFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,19 @@

use Doctrine\ORM\EntityRepository;
use Symfony\UX\Autocomplete\Tests\Fixtures\Entity\Product;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

/**
* @extends ModelFactory<Product>
*
* @method static Product|Proxy createOne(array $attributes = [])
* @method static Product[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static Product|Proxy find(object|array|mixed $criteria)
* @method static Product|Proxy findOrCreate(array $attributes)
* @method static Product|Proxy first(string $sortedField = 'id')
* @method static Product|Proxy last(string $sortedField = 'id')
* @method static Product|Proxy random(array $attributes = [])
* @method static Product|Proxy randomOrCreate(array $attributes = []))
* @method static Product[]|Proxy[] all()
* @method static Product[]|Proxy[] findBy(array $attributes)
* @method static Product[]|Proxy[] randomSet(int $number, array $attributes = []))
* @method static Product[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
* @method static EntityRepository|RepositoryProxy repository()
* @method Product|Proxy create(array|callable $attributes = [])
* @extends PersistentObjectFactory<Product>
*/
final class ProductFactory extends ModelFactory
final class ProductFactory extends PersistentObjectFactory
{
protected function getDefaults(): array
public static function class(): string
{
return Product::class;
}

protected function defaults(): array
{
return [
'name' => self::faker()->text(),
Expand All @@ -47,18 +35,8 @@ protected function getDefaults(): array
];
}

protected function initialize(): self
{
return $this;
}

public function disable(): self
{
return $this->addState(['isEnabled' => false]);
}

protected static function getClass(): string
{
return Product::class;
return $this->with(['isEnabled' => false]);
}
}
37 changes: 9 additions & 28 deletions src/Autocomplete/tests/Fixtures/Factory/ProductTagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,24 @@
use Doctrine\ORM\EntityRepository;
use Symfony\UX\Autocomplete\Tests\Fixtures\Entity\ProductTag;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
* @extends ModelFactory<ProductTag>
*
* @method static ProductTag|Proxy createOne(array $attributes = [])
* @method static ProductTag[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static ProductTag|Proxy find(object|array|mixed $criteria)
* @method static ProductTag|Proxy findOrCreate(array $attributes)
* @method static ProductTag|Proxy first(string $sortedField = 'id')
* @method static ProductTag|Proxy last(string $sortedField = 'id')
* @method static ProductTag|Proxy random(array $attributes = [])
* @method static ProductTag|Proxy randomOrCreate(array $attributes = [])
* @method static ProductTag[]|Proxy[] all()
* @method static ProductTag[]|Proxy[] findBy(array $attributes)
* @method static ProductTag[]|Proxy[] randomSet(int $number, array $attributes = [])
* @method static ProductTag[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
* @method static EntityRepository|RepositoryProxy repository()
* @method ProductTag|Proxy create(array|callable $attributes = [])
* @extends PersistentObjectFactory<ProductTag>
*/
final class ProductTagFactory extends ModelFactory
final class ProductTagFactory extends PersistentObjectFactory
{
protected function getDefaults(): array
{
return [
'name' => self::faker()->word(),
];
}

protected function initialize(): self
public static function class(): string
{
return $this;
return ProductTag::class;
}

protected static function getClass(): string
protected function defaults(): array
{
return ProductTag::class;
return [
'name' => self::faker()->word(),
];
}
}
8 changes: 1 addition & 7 deletions src/Autocomplete/tests/Fixtures/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ protected function configureContainer(ContainerConfigurator $c): void
'default_path' => '%kernel.project_dir%/tests/Fixtures/templates',
]);

$c->extension('zenstruck_foundry', [
'auto_refresh_proxies' => false,
]);
$c->extension('zenstruck_foundry', []);

$doctrineConfig = [
'dbal' => ['url' => '%env(resolve:DATABASE_URL)%'],
Expand Down Expand Up @@ -155,10 +153,6 @@ protected function configureContainer(ContainerConfigurator $c): void
],
]);

$c->extension('zenstruck_foundry', [
'auto_refresh_proxies' => false,
]);

$services = $c->services();
$services
->defaults()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testIsAssociation(): void
public function testGetIdValue(): void
{
$product = ProductFactory::createOne();
$this->assertEquals($product->getId(), $this->getMetadata()->getIdValue($product->object()));
$this->assertEquals($product->getId(), $this->getMetadata()->getIdValue($product));
}

public function testGetPropertyDataType(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testItCreatesBasicStringSearchQuery(): void
$prod4 = ProductFactory::createOne(['description' => 'all about prod 4']);

$results = $this->callAddSearchClass('prod');
$this->assertSame([$prod1->object(), $prod2->object(), $prod4->object()], $results);
$this->assertSame([$prod1, $prod2, $prod4], $results);
}

public function testItSearchesOnCorrectFields(): void
Expand All @@ -43,7 +43,7 @@ public function testItSearchesOnCorrectFields(): void
ProductFactory::createOne(['description' => 'foo prod2']);

$results = $this->callAddSearchClass('prod', ['name']);
$this->assertSame([$prod1->object()], $results);
$this->assertSame([$prod1], $results);
}

public function testItCanSearchOnRelationFields(): void
Expand All @@ -55,7 +55,7 @@ public function testItCanSearchOnRelationFields(): void
ProductFactory::createOne(['name' => 'puzzle', 'category' => $category2]);

$results = $this->callAddSearchClass('food', ['name', 'category.name']);
$this->assertSame([$prod1->object(), $prod2->object()], $results);
$this->assertSame([$prod1, $prod2], $results);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/LiveComponent/tests/Fixtures/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ protected function configureContainer(ContainerConfigurator $c): void
'anonymous_template_directory' => 'components/',
]);

$c->extension('zenstruck_foundry', [
'auto_refresh_proxies' => false,
]);
$c->extension('zenstruck_foundry', []);

$doctrineConfig = [
'dbal' => [
Expand Down
Loading