Git Product home page Git Product logo

jbalieux / fork-foundry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zenstruck/foundry

0.0 0.0 0.0 709 KB

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

Home Page: https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html

License: MIT License

Shell 0.04% JavaScript 0.05% PHP 98.04% Makefile 1.46% Dockerfile 0.40%

fork-foundry's Introduction

Foundry

CI Status Code Coverage Latest Version

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

How to contribute

The test suite of this library needs one or more database, and static analysis needs to be ran on the smaller PHP version supported (currently PHP 7.2), then it comes with a full docker stack.

Install docker

You must install docker and install docker-compose at first before running the tests.

Run tests

The library is shipped with a Makefile to run tests. Each target will build and start the docker stack and install composer only if needed.

$ make help
validate                       Run fixcs, sca, full test suite and validate migrations
test-full                      Run full PHPunit (MySQL + Mongo)
test-fast                      Run PHPunit with SQLite
test-mysql                     Run PHPunit with mysql
test-postgresql                Run PHPunit with postgreSQL
test-mongo                     Run PHPunit with Mongo
fixcs                          Run PHP CS-Fixer
sca                            Run Psalm
database-generate-migration    Generate new migration based on mapping in Zenstruck\Foundry\Tests\Fixtures\Entity
database-validate-mapping      Validate mapping in Zenstruck\Foundry\Tests\Fixtures\Entity
database-drop-schema           Drop database schema
docker-start                   Build and run containers
docker-stop                    Stop containers
docker-purge                   Purge containers
composer                       Run composer command
clear                          Start from a fresh install (needed if vendors have already been installed with another php version)

You can run each test-* target with a special argument filter:

$ make test-mysql filter=FactoryTest

which will use PHPUnit's --filter option.

Change docker's ports

You can create a .env file to change the ports used by docker:

MYSQL_PORT=3307
POSTGRES_PORT=5434
MONGO_PORT=27018

Execute commands in php container

You can execute any command into the php container using docker compose:

$ docker-compose exec php [you commmand] # or "docker compose" depending on your docker compose version

Using xdebug with PhpStorm

The php container is shipped with xdebug activated. You can use step by step debugging session with PhpStorm: you should create a server called FOUNDRY in your PHP Remote Debug, with the IDE key xdebug_foundry

PhpStorm with xdebug

Run tests without docker

If for any reason docker is not available on your computer, the target make test-fast will run tests with your local php version, and sqlite will be used as database. Results may differ from the CI!

Migrations

Whenever an entity in the fixtures is added or updated a migration must be generated with make migrations-generate

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.

fork-foundry's People

Contributors

kbond avatar wouterj avatar nikophil avatar nyholm avatar dependabot[bot] avatar gnito-org avatar jmsche avatar jdreesen avatar mpiot avatar chris53897 avatar weaverryan avatar northblue333 avatar jschaedl avatar abeal-hottomali avatar seb-jean avatar gazzatav avatar domagoj-orioly avatar bfoks avatar zairigimad avatar tavoniievez avatar ker0x avatar oskarstark avatar ndench avatar micheh avatar babeuloula avatar jordisala1991 avatar hypemc avatar benblub avatar antoineroue avatar ettalhaoui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.