196 search results

User Roles

…we're creating his user. Add 'roles' => , and in an array, ROLE_CAPTAIN: At your terminal, reload the fixtures with: symfony console foundry:load-fixtures Reload the page... we're logged out because we reloaded the fixtures. Log back in... Nice, we're in…

5:47
PHP 8.4 & Recipe Updates

…from Doctrine. We'll have a whole chapter on upgrading Doctrine a little later, so we'll ignore these for now. The fourth one is a deprecated config option from zenstruck/foundry. Before manually fixing this, let's first update our Symfony Flex recipes. Sometimes…

11:21
Understanding Password Hashing

…from the terminal and open src/Story/AppStory.php. Replace the plain text password for makeitso with the copied hash: Back in the terminal, reload our fixtures with: symfony console foundry:load-fixtures Go back to our login page... refresh... enter makeitso as the password..…

9:51
Cosmic Queries: the Repository Class

…second is the findAll() from findMyShip(). Perfect! Next, let's improve our fixtures and make them 100 times more fun with a library called Foundry. This will let us create a whole fleet of Starships as if we had a replicator. Let's do it!

5:15
Mapped Superclasses

…scout. Let's see how this plays out when we reload the fixtures for our app. Run: symfony console foundry:load-fixtures Here's a snag: we can't instantiate the abstract class Starship. We're using Foundry factories, and since Starship is now abstract…

4:05
Testing a Service

…created the $lockDown variable through Foundry, it's wrapped in a Proxy. One of the main features of a Proxy is called "auto-refreshing". Each time you access a property or call a method on your entity, behind the scenes, Foundry queries for the latest…

7:31
Bootstrapping a Killer Test System

…But that's way too much work. Instead, add one more trait to our test class: use ResetDatabase: This comes from Foundry: the library we've been using to create dummy fixtures via the factory classes. ResetDatabase is amazing. It automatically makes sure that the…

8:18
Running Code "On Publish"

… At the end of the test, say NotificationFactory - that's a Foundry factory that I created, ::repository() - to get a repository helper - then ->assert()->count(1). With Foundry, our database is always empty at the start of a test: so checking for 1 row is…

6:05
Upgrading Encore and your assets/ Setup

…fixed all of the conflicts... and commit! Now, dear friends, we are on the last update. It's zenstruck/foundry. This is an easy one. Run: git status It is, once again, environment configuration going into a main file. So let's commit that. And..…

8:22
Data Fixtures

…especially once you have database relationships where objects are linked to other objects... these classes can get ugly fast. And they're not much fun to write. So, next: let's use a shiny new library called Foundry to create numerous, random, rich dummy data.

5:18
18 lines | config/packages/zenstruck_foundry.yaml
when@dev: &dev
// ... line 2
zenstruck_foundry:
enable_auto_refresh_with_lazy_objects: true
// ... lines 5 - 18
See Code Block in Script
so foundry generates a "Factory", so what do I call my acctual (non fixtures) factories then? Or is a foundry factory supposed to be used (i.e. replace my existing entity factories?) for generating non-fixtures also? It's a bit confusing.
// ... lines 1 - 5
use Zenstruck\Foundry\Test\ResetDatabase;
class LemonSqueezyRequestParserTest extends WebTestCase
{
use ResetDatabase;
// ... lines 11 - 18
}
See Code Block in Script
// ... lines 1 - 8
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
// ... line 11
class LockDownRepositoryTest extends KernelTestCase
{
use ResetDatabase, Factories;
// ... lines 15 - 42
}
See Code Block in Script
I tried using foundry, but it's not clear how to override the createOne method (if you need to do some custom work). Is there somewhere that has more comprehensive information on how to use this? It would be great if you guys had some…
// ... lines 1 - 4
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
class DailyQuestResourceTest extends ApiTestCase
{
use ResetDatabase;
use Factories;
}
See Code Block in Script
79 lines | composer.json
{
// ... lines 2 - 3
"require": {
// ... lines 5 - 29
"zenstruck/foundry": "^1.1"
},
// ... lines 32 - 77
}
See Code Block in Script
whats is Foundry O.o ?
…hoping that Foundry had something similar to: ``` doctrine:fixtures:load --purge-exclusions=doctrine_migrations_versions ``` Or even maybe something in the configuration to exclude tables. I believe Doctrine has a way to create your own Purger class so you can control it. Does Foundry have something…
JeffJones
JeffJones
Read Full Comment
ModelFactory has been deprecated in zenstruck/foundry from version 2 so the addState method in the tutorial does not exist anymore. Anyway it is safe to use: `$admin = UserFactory::createOne((['roles' => ['ROLE_ADMIN']]));`
Abraham-C
Abraham-C
Read Full Comment