Skip to content

Releases: zenstruck/foundry

v2.2.2

05 Nov 16:39
Compare
Choose a tag to compare

3282f24 Remove @internal from db resetter interfaces (#715) by @HypeMC
870cb42 docs: fix missing comma in upgrade doc (#718) by @justpilot

Full Change List

v2.2.1

31 Oct 12:10
Compare
Choose a tag to compare

496a7a8 fix: Change RepositoryDecorator::inner() visibility to public (#714) by @marienfressinaud
dfeb247 chore: test Foundry on PHP 8.4 & sf 7.2 (#709) by @nikophil
2b12ef0 chore: simplify CI matrix (#708) by @nikophil

Full Change List

v2.2.0

24 Oct 12:27
a549c10
Compare
Choose a tag to compare

Main features to use Factory::create() and factory service in data providers

2014ed9 feature: allow to use Factory::create() and factory service in data providers (#648) by @nikophil

From version 2.2, Foundry provides an extension for PHPUnit.
You can install it by modifying you phpunit.xml.dist:

    <phpunit>
      <extensions>
        <bootstrap class="Zenstruck\Foundry\PHPUnit\FoundryExtension"/>
      </extensions>
    </phpunit>

Warning

This PHPUnit extension requires at least PHPUnit 11.4.

Using this extension will allow to use your factories in your data providers the same way you're using them in tests.
Thanks to it, you can:

  • Call ->create() or ::createOne() or any other method which creates objects in unit tests
    (using PHPUnit\Framework\TestCase) and functional tests (Symfony\Bundle\FrameworkBundle\Test\KernelTestCase)
  • Use "Factories as Services" in functional tests
  • Use faker() normally, without wrapping its call in a callable

Make "database reset" mechanism extendable

df568da refactor: make "database reset" mechanism extendable (#690) by @nikophil

The reset mechanism can now be extended thanks to decoration:

    use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
    use Symfony\Component\DependencyInjection\Attribute\When;
    use Symfony\Component\HttpKernel\KernelInterface;
    use Zenstruck\Foundry\ORM\ResetDatabase\OrmResetter;

    // The decorator should be declared in test environment only.
    #[When('test')]
    // You can also decorate `MongoResetter::class`.
    #[AsDecorator(OrmResetter::class)]
    final readonly class DecorateDatabaseResetter implements OrmResetter
    {
        public function __construct(
            private OrmResetter $decorated
        ) {}

        public function resetBeforeFirstTest(KernelInterface $kernel): void
        {
            // do something once per test suite (for instance: install a PostgreSQL extension)

            $this->decorated->resetBeforeFirstTest($kernel);
        }

        public function resetBeforeEachTest(KernelInterface $kernel): void
        {
            // do something once per test case (for instance: restart PostgreSQL sequences)

            $this->decorated->resetBeforeEachTest($kernel);
        }
    }

Add a Psalm Extension

0d570cc refactor: fix proxy system and introduce psalm extension (#704) by @nikophil

A Psalm extension is now shipped with the library and makes Psalm happy with your factories.
You can enable it with:

.. code-block:: terminal

$ vendor/bin/psalm-plugin enable zenstruck/foundry

Minor PRs

a549c10 docs: using factories in data providers (#707) by @nikophil
470d927 docs: how to extend database reset mechanism (#706) by @nikophil
4fb0b25 docs: add missing docs (#703) by @nikophil
fa1d527 minor: misc fixes for sca (#705) by @nikophil

Full Change List

v2.1.0

03 Oct 11:57
0f72ea5
Compare
Choose a tag to compare

0f72ea5 fix: allow non object state in stories (#699) by @Brewal
6482357 feat: allow to configure migrations configuration files (#686) by @MatTheCat

Full Change List

v2.0.9

02 Sep 18:21
b0a5d3d
Compare
Choose a tag to compare

b0a5d3d Fix Psalm TooManyTemplateParams (#693) by @ddeboer

Full Change List

v2.0.8

29 Aug 07:00
3eebbf9
Compare
Choose a tag to compare

3eebbf9 Have flush_after() return the callback's return (#691) by @HypeMC
33d5870 doc: Fix range call instead of many (#688) by @ternel
33595b9 chore: add a wrapper for PHPUnit binary (#683) by @nikophil
8bf8c4c docs: Fix CategoryStory codeblock (#681) by @smnandre
f89d43e doc: Minor fixes (#679) by @smnandre
65c1cc2 fix: add phpdoc to improve proxy factories autocompletion (#675) by @nikophil

Full Change List

v2.0.7

12 Jul 16:00
Compare
Choose a tag to compare

5c44991 fix: handle proxies when refreshing entity in Proxy::getState() (#672) by @nikophil
49f5e1d Fix faker php urls (#671) by @BackEndTea
7719b0d chore(CI): Enable documentation linter (#657) by @cezarpopa

Full Change List

v2.0.6

04 Jul 20:02
4780e1a
Compare
Choose a tag to compare

52ca7b7 fix: only restore error handler for PHPUnit 10 or superior (#668) by @nikophil
b5090aa docs: Fix broken link to Without Persisting (#660) by @simoheinonen
35b0404 feat: re-add Proxy assertions (#663) by @nikophil

Full Change List

v1.38.3

04 Jul 20:00
112e3a6
Compare
Choose a tag to compare

112e3a6 fix: only restore error handler for PHPUnit 10 or superior (#669) by @nikophil
bad65a2 fix(1.x): re-introduce Proxy assertion methods (#665) by @nikophil

Full Change List

v2.0.5

03 Jul 14:03
6105a36
Compare
Choose a tag to compare

6105a36 fix: make proxy work with last symfony/var-exporter version (#664) by @nikophil
e8623a3 [DOC] Fix Upgrade Guide URL Rendering (#654) by @cezarpopa
f7f133a fix: create ArrayCollection if needed (#645) by @nikophil
779bee4 fix: after_flush() can use objects created in global state (#653) by @nikophil
72e48bf tests(ci): add test permutation for PHPUnit >= 10 (#647) by @nikophil
1edf948 docs: fix incoherence (#652) by @nikophil
1c66e39 minor: improve repository assertion messages (#651) by @nikophil

Full Change List