185 search results

foundry 2 added a bunch of breaking changes - there is a [migration path for 1.x-2.x](https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.0.md) you can take a look at. In the meantime, no problem staying on foundry 1…
I'm getting some strange deprecation warnings from (it appears: ) foundry: 09:55:55 INFO [deprecation] User Deprecated: Method Doctrine\ORM\Event\LifecycleEventArgs::getEntityManager() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead. (LifecycleEventArgs.php:63 called by ORM.php…
Thanks, i renamed foundry namespace from 'factory' to 'foundry' to keep it seperate from factories that do a better job building non-fixture entities.
I must install this bundle -> `composer require zenstruck/foundry --dev`
pasquale_pellicani
pasquale_pellicani
Read Full Comment
Hi, is it possible to use references in Foundry? Earlier, I used setReference in Fixtures (inherited from AbstractFixture($this->setReference('key', $object))) and could refer to special objects like roles. Does Foundry have a similar feature (getReference('key')) for this case which I can use…
Hey Tien dat L. Foundry is expecting the Question class to have a way to set the tags, in this case it's expecting a public `setTags()` method. Could you check if that method exist? Cheers!
MolloKhan
MolloKhan
Read Full Comment
Hey Brainiac, Yes, Foundry definitely adds more overhead into your project than just simple fixtures, but it also provides more features out of the box. To know more about the features it brings - please, watch this screencast. Also, in the next video we cover some…
// ... lines 1 - 4
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
class LockDownHelperTest extends KernelTestCase
{
use ResetDatabase, Factories;
}
See Code Block in Script
16 lines | tests/Functional/UserResourceTest.php
// ... lines 1 - 2
namespace App\Tests\Functional;
use Zenstruck\Foundry\Test\ResetDatabase;
class UserResourceTest extends ApiTestCase
{
use ResetDatabase;
// ... lines 10 - 14
}
See Code Block in Script
Hey all, this should be fixed in Foundry v1.1.2 (https://github.com/zenstruck/foundry/releases/tag/v1.1.2) - I allow doctrine/persistence v2
54 lines | src/Factory/QuestionFactory.php
// ... lines 1 - 20
final class QuestionFactory extends ModelFactory
{
// ... lines 23 - 35
protected function initialize(): self
{
// see https://github.com/zenstruck/foundry#initialization
return $this
->afterInstantiate(function(Question $question) {
if (!$question->getSlug()) {
// ... lines 42 - 43
}
})
;
}
// ... lines 48 - 52
}
See Code Block in Script
54 lines | src/Factory/QuestionFactory.php
// ... lines 1 - 20
final class QuestionFactory extends ModelFactory
{
// ... lines 23 - 40
protected function initialize(): self
{
// see https://github.com/zenstruck/foundry#initialization
return $this
//->afterInstantiate(function(Question $question) { });
;
}
// ... lines 48 - 52
}
See Code Block in Script
Hey Ruslan, No problem :) Btw, you can use ResetDatabase trait from Foundry lib in your tests to automatically prepare test DB before each test :) Cheers!
…, Indeed, I used foundry v2.1.0 and browser v1.9.0. I ran `composer update zenstruck/browser`, which brought my browser version to 1.9.1 and it seems to solve the issue. I can now use `browser->actingAs($user)` with `$user` generated with…
… Can you tell me what version of `zenstruck/browser` & `zenstruck/foundry` you are using? ``` composer show zenstruck/browser composer show zenstruck/foundry ``` (I'm thinking you may be on foundry 2+ but your browser version does not support it yet - I'm hoping upgrading `zenstruck…
I reviewed that documentation yes, thank you. It was not clear to me that foundry was *only* for fixtures, as it's use of the 'factory' namespace (to me at least) implies it's purpose as a non-fixture factory also. I was looking to…
Hey Rufnex, Yep, exactly like Ruslan mentioned below in https://symfonycasts.com/screencast/symfony-doctrine/foundry#comment-27727 I.e. you create a faker instance manually via `$faker = Factory::create('fr_FR');` passing the desired locale and then use it below. Cheers!
…talking about how to localize Faker with the Foundry bundle - here's an example: https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#faker . As you can see from the docs, you can do it via Symfony configuration: ```yaml # config/packages/zenstruck_foundry.yaml when@dev: #…
Hallo, i habe a issue with Relation ManyToMany in Foundry 1.21 and Symfony 6 in AppFixtrures: ` TagFactory::createMany(100); $questions = QuestionFactory::createMany(20, function() { return [ 'tags' => TagFactory::randomRange(0, 5), ]; }); ` i got error from doctrine orm : Cannot set attribute "tags" for object…
Tien dat L.
Tien dat L.
Read Full Comment
Struggling with this one. I keep getting the error "The class 'Zenstruck\Foundry\Proxy' was not found in the chain configured namespaces App\Entity" and there are some deprecation warnings if I turn the volume up (-vvv). It happens when I add this code: ` $tag1…