@@ -96,6 +96,18 @@ function purge(): void
9696 success (exit_code ('rm -rf ./var/cache/* ./var/log/* ./var/coverage/* ' ));
9797}
9898
99+ #[AsTask(namespace: 'app ' , description: 'Load the database fixtures ' , aliases: ['load-fixtures ' ])]
100+ function loadFixtures (): void
101+ {
102+ title ('app:load-fixtures ' );
103+ io ()->note ('Resetting db... ' );
104+ success (exit_code ('rm -f ./var/data.db ' ));
105+ io ()->note ('Running db migrations... ' );
106+ success (exit_code ('bin/console doctrine:migrations:migrate --no-interaction ' ));
107+ io ()->note ('Load fixtures... ' );
108+ success (exit_code ('bin/console foundry:load-fixtures --env=dev --no-interaction ' ));
109+ }
110+
99111const PHP_UNIT_CMD = '/vendor/bin/phpunit --testsuite=%s --filter=%s %s ' ;
100112const PHP_UNIT_SUITES = ['api ' , 'e2e ' , 'functional ' , 'integration ' , 'unit ' ];
101113
@@ -111,6 +123,7 @@ function getParameters(): array
111123function test_all (): int
112124{
113125 title ('test:all ' );
126+ loadFixtures ();
114127 [$ filter , $ options ] = getParameters ();
115128 $ ec = exit_code (__DIR__ .sprintf (PHP_UNIT_CMD , implode (', ' , PHP_UNIT_SUITES ), $ filter , $ options ));
116129 io ()->writeln ('' );
@@ -177,6 +190,7 @@ function test_unit(
177190function coverage (): int
178191{
179192 title ('test:coverage ' );
193+ loadFixtures ();
180194 $ ec = exit_code ('php -d xdebug.enable=1 -d memory_limit=-1 vendor/bin/phpunit --coverage-html=var/coverage --coverage-clover=var/coverage/clover.xml ' ,
181195 context: context ()->withEnvironment (['XDEBUG_MODE ' => 'coverage ' ])
182196 );
@@ -341,6 +355,7 @@ function ci(): void
341355{
342356 title ('ci:all ' );
343357 purge ();
358+ loadFixtures ();
344359 io ()->section ('Coverage ' );
345360 coverage ();
346361 io ()->section ('Lints ' );
0 commit comments