ProductPromotion
Logo

PHP

made by https://0x3d.site

GitHub - zenstruck/foundry: A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine. - zenstruck/foundry
Visit Site

GitHub - zenstruck/foundry: A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.

GitHub - zenstruck/foundry: A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.

Foundry

CI Status Code Coverage Latest Version Downloads

Foundry makes creating fixtures data fun again, via an expressive, auto-completable, on-demand fixtures system with Symfony and Doctrine:

$post = PostFactory::new() // Create the factory for Post objects
    ->published()          // Make the post in a "published" state
    ->create([             // create & persist the Post object
        'slug' => 'post-a' // This Post object only requires the slug field - all other fields are random data
    ])
;

The factories can be used inside DoctrineFixturesBundle to load fixtures or inside your tests, where it has even more features.

Foundry supports doctrine/orm (with doctrine/doctrine-bundle), doctrine/mongodb-odm (with doctrine/mongodb-odm-bundle) or a combination of these.

Want to watch a screencast 🎥 about it? Check out https://symfonycasts.com/foundry

Read the Documentation Upgrade guide to v2

How to contribute

Running the Test Suite

The test suite of this library needs one or more databases, then it comes with a docker compose configuration.

[!NOTE] Docker and PHP installed locally (with mysql, pgsql & mongodb extensions) is required.

You can start the containers and run the test suite:

# start the container
$ docker compose up --detach

# install dependencies
$ composer update

# run test suite with all available permutations
$ composer test

# run only one permutation
$ ./phpunit

# run test suite with dama/doctrine-test-bundle
$ USE_DAMA_DOCTRINE_TEST_BUNDLE=1 vendor/bin/phpunit

# run test suite with postgreSQL instead of MySQL
$ DATABASE_URL="postgresql://zenstruck:[email protected]:5433/zenstruck_foundry?serverVersion=15" vendor/bin/phpunit

# run test suite with another PHPUnit version
$ PHPUNIT_VERSION=10 vendor/bin/phpunit

Overriding the default configuration

You can override default environment variables by creating a .env.local file, to easily enable permutations:

# .env.local
DATABASE_URL="postgresql://zenstruck:[email protected]:5433/zenstruck_foundry?serverVersion=15" # enables postgreSQL instead of MySQL
MONGO_URL="" # disables Mongo
USE_DAMA_DOCTRINE_TEST_BUNDLE="1" # enables dama/doctrine-test-bundle
PHPUNIT_VERSION="11" # possible values: 9, 10, 11, 11.4

# run test suite with postgreSQL
$ vendor/bin/phpunit

The .env.local file can also be used to override the port of the database containers, if it does not meet your local requirements. You'll also need to override docker compose configuration:

Here is an example to use MySQL on port 3308:

# docker-compose.override.yml
version: '3.9'

services:
    mysql:
        ports:
            - "3308:3306"
# .env.local
DATABASE_URL="mysql://root:[email protected]:3308/foundry_test?serverVersion=5.7.42"

Running the documentation linter locally

This section provides guidance on how to run the documentation linter, contained within a Docker image, locally on your machine. This linter is designed to verify and ensure that the document syntax adheres to the required standards.

The following command runs the linter in the local directory:

docker run --rm -it -e DOCS_DIR='/docs' -v ${PWD}/docs:/docs  oskarstark/doctor-rst:latest

Credit

The AAA style of testing was first introduced to me by Adam Wathan's excellent Test Driven Laravel Course. The inspiration for this libraries API comes from Laravel factories and christophrumpel/laravel-factories-reloaded.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory