1616// use function Castor\parallel;
1717
1818// You can modify the coverage threshold here
19- const COVERAGE_THRESHOLD = 100 ;
19+ const COVERAGE_THRESHOLD = 80 ;
2020
2121function title (string $ name ): void
2222{
@@ -93,10 +93,21 @@ function purge(): void
9393 success (exit_code ('rm -rf ./var/cache/* ./var/logs/* ./var/coverage/* ' ));
9494}
9595
96+ #[AsTask(namespace: 'app ' , description: 'Load the database fixtures ' , aliases: ['load-fixtures ' ])]
97+ function loadFixures (): void
98+ {
99+ title ('app:load-fixtures ' );
100+ io ()->note ('Resetting db... ' );
101+ success (exit_code ('rm -f ./var/data.db && touch ./var/data.db ' ));
102+ io ()->note ('Running db migrations and load fixtures... ' );
103+ success (exit_code ('bin/console eloquent:migrate:fresh --seed ' ));
104+ }
105+
96106#[AsTask(name: 'all ' , namespace: 'test ' , description: 'Run all PHPUnit tests ' , aliases: ['test ' ])]
97107function test_all (): int
98108{
99109 title ('test:all ' );
110+ loadFixures ();
100111 $ ec = exit_code (__DIR__ .'/vendor/bin/phpunit ' );
101112 io ()->writeln ('' );
102113
@@ -107,6 +118,7 @@ function test_all(): int
107118function coverage (): int
108119{
109120 title ('test:coverage ' );
121+ loadFixures ();
110122 $ 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 ' ,
111123 context: context ()->withEnvironment (['XDEBUG_MODE ' => 'coverage ' ])
112124 );
@@ -238,6 +250,7 @@ function ci(): void
238250{
239251 title ('ci:all ' );
240252 purge ();
253+ loadFixures ();
241254 io ()->section ('Coverage ' );
242255 coverage ();
243256 io ()->section ('Codings standards ' );
0 commit comments