…for my database, and when using the ResetDatabase trait I am unable to run my tests. They fail as foundy cannot drop the database because it is in use. The connection that is in use is the Test script that is running. Did i miss…
…cryptic
Darn, we've been trying to [make this error](https://github.com/zenstruck/foundry/blob/0a65872885d63c826ff6f0ef022b0fa8ff7187af/src/Exception/FactoriesTraitNotUsed.php#L30) more helpful but it's a bit hacky and we can't seem to catch every scenario.
Regardless, I'm glad you solved…
…at the top of my test case. Since the previous examples (running with `--filter=....`) ran fine, I didn't think it was necessary.
So if you're using a newer version of Symfony/Doctrine/Foundry, you should add `use Factories;` to your test case or…
…able to create Foundry factories in your project. However, if you already have the foundry installed in your project - than `make:factory` will just work for you, so no need to run that `composer require --dev factory`. Moreover, if you have Foundry lib already installed…
Blog
SymfonyCasts November Open Source Roundup!
…object to another!
SymfonyCasts/dynamic-forms: v0.1.3
Add dynamic/dependent fields to Symfony forms
zenstruck/phpmyadmin-server: v1.9.0
Run phpMyAdmin in the background with a PHP webserver
zenstruck/foundry: v2.2.2
A model factory library for creating expressive, auto-completable…
…as it comes to this module where we have the first access to DB, DB access fails complete. It is that the whole zenstruck part is depecreated and not working anymore with zenstruck/foundry >= ^2. I do not see any database item at all.
Blog
Kevin Bond (aka Zenstruck) joins SymfonyCasts
…to use his libraries and has repeatedly taken a hard or ugly task in Symfony and made it easy and beautiful. Just look at Foundry (for data fixtures - including inside tests), zenstruck/browser (for functional tests) or a number of other libraries for testing emails…
…in your app, have other classes that have nothing to do with Foundry but which follow the factory pattern. Unless it's confusing for you, there is nothing wrong with having non-Foundry classes that also live in `src/Factory/`. If you don't like…
…of Foundry, I had add trait of ResetDatabase and Factories to the fixture-tests, because a single RoleFactory call had some problems with $entitymanager->flush(). After adding the traits my test-code was running very slowly and interrupted. So I stopped my experiment with Foundry…
…objects I'm looking for. Or use foundry to find random items - e.g.
```
ProductFactory::createOne([
'category' => CategoryFactory::random()
]);
```
But, to answer your question.... yes and no! :p. The answer is no. But, that's actually by design. With Foundry, you are still using…
…
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;
/**
* @extends ModelFactory
*
* @method User|Proxy create(array|callable $attributes = [])
* @method static User|Proxy createOne(array $attributes = [])
* @method static User|Proxy find(object|array|mixed $criteria)
* @method static User|Proxy findOrCreate(array $attributes…
…User::class;
}
}
```
They key thing is your `User` class needs to have a getter and setter for `User::address` and `Address` of course needs getters/setters for it's respective properties.
Then you just use foundry as you would with any other entity. E.g…
…generate data with it? Are those data really localized? If so, it sounds like a misconfiguration or a bug in the Foundry bundle, I'd recommend you to open an issue there.
Btw, keep in mind that not all the data might be translated. Please…
…it required to download somewhere the language packs?
```
Current configuration for extension with alias "zenstruck_foundry"
==================================================================
zenstruck_foundry:
auto_refresh_proxies: true
faker:
locale: fr_FR
seed: null
service: null
instantiator:
without_constructor: false
allow_extra_attributes: false
always_force_properties: false
service: null
```
…please, make sure your current config really has that locally, you can debug it with:
```bash
bin/console debug:config zenstruck_foundry
```
Is the locale set there? Also, make sure you're debugging this config for the environment that your Symfony application is currently using…
…the course code for this tutorial *is* now old - we'll update the tutorials soon for API Platform 3.
Also, in newer projects, instead of Alice, we use Foundry for data fixtures and for resetting the database between tests - https://github.com/zenstruck/foundry
Cheers!
…part where it needs to be holistic.
As an exercise I'm also working on integrating zenstruck/foundry and upgrading the security as that all changed in 5.3.
Currently the javascript seems to be a bit broken, this needs the liip_imagine bundle and…
…my own constructor. I realise now that it's a good idea to diff my files with the start files to check on updates that are there because of deprecations etc.
There is no use statement for Zenstruck\Foundry\Proxy in the course. The error…
… Lesson learned!
I kept getting a badly worded error:
"User Deprecated: Since zenstruck/foundry 1.7: Calling instance method "App\Factory\QuestionFactory::createMany()" is deprecated and will be removed in 2.0, use the static "App\Factory\QuestionFactory:createMany()" method instead.
If you're adding…
…below. In particular look at the single colon in the preferred method which otherwise looks exactly the same as the deprecated one.
User Deprecated: Since zenstruck/foundry 1.7: Calling instance method "App\Factory\QuestionFactory::createMany()" is deprecated and will be removed in
2.0…
x
178