@@ -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 loadFixures (): 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:migration:migrate --no-interaction ' ));
107+ io ()->note ('Load fixtures... ' );
108+ success (exit_code ('bin/console app:load-fixtures --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,8 @@ function getParameters(): array
111123function test_all (): int
112124{
113125 title ('test:all ' );
126+ loadFixures ();
127+ $ ec = exit_code (__DIR__ .'/vendor/bin/phpunit ' );
114128 [$ filter , $ options ] = getParameters ();
115129 $ ec = exit_code (__DIR__ .sprintf (PHP_UNIT_CMD , implode (', ' , PHP_UNIT_SUITES ), $ filter , $ options ));
116130 io ()->writeln ('' );
@@ -177,6 +191,7 @@ function test_unit(
177191function coverage (): int
178192{
179193 title ('test:coverage ' );
194+ loadFixures ();
180195 $ 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 ' ,
181196 context: context ()->withEnvironment (['XDEBUG_MODE ' => 'coverage ' ])
182197 );
@@ -341,6 +356,7 @@ function ci(): void
341356{
342357 title ('ci:all ' );
343358 purge ();
359+ loadFixures ();
344360 io ()->section ('Coverage ' );
345361 coverage ();
346362 io ()->section ('Lints ' );
0 commit comments