178 search results

Factory Data Seeding

…handy. But it's actually wrapped in a special proxy object. So if we run the test now, you can see it's a proxy... and the LockDown is hiding inside. Why does Foundry do that? Well, if you go and find their documentation, they…

5:56
Course

Pro Testing

PHPUnit: Integration Testing with Live Services

… When do I need that? Accessing services from the container Clearing the database between tests Seeding the database Foundry Factories & more! Partial Mocking: mock just some dependencies Testing emails Testing messenger messages Integration tests are fun and are a critical tool to a well-rounded…

10 videos
|
1:02:48
Custom Resource State Processor

…tests/Functional/, create a new class called DailyQuestResourceTest. Make this extend the ApiTestCase that we created in the last tutorial and use ResetDatabase from Foundry to make sure our database is empty at the start of every test. Also use Factories. Ok, we don't…

6:48
Doctrine, Symfony 6 & the Database

…with Docker via the Flex recipe system Database config Creating (and updating) Entities with make:entity Generating & using migrations Inserting new data Fetching & Querying for data Doctrine Repositories Custom queries and the query builder Fixtures (Dummy data) using Foundry Relationships & Associations SELECT * FROM doctrine_knowledge.

22 videos
|
2:28:56
Saving Relations

… This is actually pretty easy... but it might feel weird if you're used to working with databases directly. Open up src/DataFixtures/AppFixtures.php. We're using Foundry to add rich fixtures, or fake data, into our project. But to see how relationships work…

3:58
QuestionTag Fixtures & DateTimeImmutable with Faker

…reflect this. First, since we now have a QuestionTag entity, we are going to be creating and persisting QuestionTag objects directly. So let's generate a Foundry factory for it. At your terminal, run: symfony console make:factory And choose QuestionTag. Go open that up…

4:07
Detecting the "Published" State Change

…send the PUT request, there is exactly one CheeseNotification in the database. Now, thanks to Foundry - the library that helps us insert dummy data both in our data fixtures and in our tests - before each test case, our database is emptied. That will make it…

9:08
Symfony 5: Mastering Doctrine Relations

…Generating a ManyToOne relationship (association) Relation annotations / PHP 8 attributes The OneToMany inverse side of a relation Handling relationships in fixtures with Foundry The owning versus inverse sides of a relation Doing magic with the ArrayCollection (Criteria) Querying with Joins ManyToMany Relations So let's…

27 videos
|
2:45:18
Doctrine, Symfony & the Database

…s go! Booting a database with Docker via make:docker:database Database Configuration Creating (and updating) Entities with make:entity Generating & using migrations Inserting new data Fetching & Querying for data Doctrine Repositories Custom queries and the query builder Fixtures (Dummy data) using Foundry Relationships & Associations

23 videos
|
2:22:24
Class Table Inheritance

…cargo_capacity. The starship table has all the common properties, and the scout table has just an id and sensor_range. Let's load our fixtures to ensure everything still works. symfony console foundry:load-fixtures Looks good. Jump over to the app and refresh…

6:02
Single Table Inheritance

…because not all entities will have those properties, and need to be null if this is the case. Let's reload our fixtures! Run: symfony console foundry:load-fixtures Awesome, no changes needed for our fixtures. To see what our starship table looks like, run: …

5:17
Doctrine Inheritance and Relationships

… starshipParts is good. We don't need another property so just hit enter to exit. Next, create the Foundry factory for this entity. symfony console make:factory 1 for all (and all for 1). Sweet, let's take a look at the generated code. In…

8:31
Part Entity

…we need a migration! symfony console make:migration Then migrate: symfony console doctrine:migrations:migrate In the last tutorial, we used a cool library called Foundry to quickly create a bunch of dummy data. We're going to do the same for StarshipPart. Step 1 …

3:12
Many To One: The King of Relationships

…we see a handy getParts() method. But instead of setParts(), we've been gifted addPart() and removePart() methods: These will come in handy when you work with Foundry, the form system or if you're building an API with Symfony's serializer. In the constructor…

4:36
Creating a User Entity

…migrate Sweet! Though, I think our new entity deserves some juicy data fixtures. Let's use Foundry like we did for DragonTreasure. Start by running php bin/console make:factory to generate the factory for User. Like before, in the src/Factory/ directory, we have…

4:06
The Two Sides of a Relation: Owning vs Inverse

…Our favorite error pops up starship_id cannot be null Totally expected. To demonstrate the owning vs inverse issue, add _real() to the end of $starship: When you create an entity via foundry, it actually wraps it in a little gift called a proxy object…

3:52
Relating Resources

…new owner field to getDefaults() set to UserFactory::new(). I'm not going to go into the specifics of Foundry - and Foundry has great docs on how to work with relationships - but this will create a new User each time it creates a new DragonTreasure…

7:08
Generating the API Token & Fixtures

… So let's add some API tokens to the database. At your terminal, run php ./bin/console make:factory so we can generate a Foundry factory for ApiToken. Go check out the new class: src/Factory/ApiTokenFactory.php. Down in getDefaults(): This looks mostly fine…

5:58
Cascade Persist

…again: Guess what? They work! Behind the scenes, Foundry is calling addDroid() on each Starship for each droid. And we just proved that addDroid() is back in action. The creation of the StarshipDroid join entity is now hidden from our entire codebase! But, what if…

2:51
Accessing Data on a ManyToMany

…separated string. Now that we've got a getDroidNames() method, we can say {{ ship.droidNames ?: 'none' }}. We're done! Refresh... and enjoy the droid names on the homepage. Next: let's use Foundry to set the ManyToMany relationship in the fixtures. Another place Foundry shines!

2:48