Skip to content

Commit a442a8e

Browse files
committed
feat: use wouterj/eloquent-bundle
1 parent 54b251e commit a442a8e

21 files changed

+2251
-296
lines changed

.env

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ APP_SECRET=sFiChPNdQsY9TWJDLMf4FY22tCDfcxxM
2323
# To test the production environment, run "make go-prod" or "castor symfony:go-prod"
2424

2525
# To come back to the development environment, run "make go-dev" or "castor symfony:go-dev"
26+
27+
###> wouterj/eloquent-bundle ###
28+
DB_CONNECTION=sqlite
29+
#DB_HOST=127.0.0.1
30+
#DB_PORT=3306
31+
DB_DATABASE=var/data.db
32+
#DB_USERNAME=root
33+
#DB_PASSWORD=
34+
###< wouterj/eloquent-bundle ###

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ help: ## Outputs this help screen
88
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements
99

1010
# You can modify the coverage threshold here
11-
COVERAGE_THRESHOLD = 100
11+
COVERAGE_THRESHOLD = 80
1212

1313
## —— Symfony binary 💻 ————————————————————————————————————————————————————————
1414
start: ## Serve the application with the Symfony binary
@@ -36,13 +36,18 @@ warmup: ## Warmup the dev cache for the static analysis
3636
purge: ## Purge all Symfony cache and logs
3737
@rm -rf ./var/cache/* ./var/logs/* ./var/coverage/*
3838

39+
load-fixtures: ## Reset migrations and load the database fixtures
40+
@rm -f ./var/data.db
41+
@touch ./var/data.db
42+
@bin/console eloquent:migrate:fresh --seed
43+
3944

4045
## —— Tests ✅ —————————————————————————————————————————————————————————————————
41-
test: ## Run all PHPUnit tests
46+
test: purge load-fixtures ## Run all PHPUnit tests
4247
@vendor/bin/phpunit
4348

4449
coverage: ## Generate the HTML PHPUnit code coverage report (stored in var/coverage)
45-
coverage: purge
50+
coverage: purge load-fixtures
4651
@XDEBUG_MODE=coverage php -d xdebug.enable=1 -d memory_limit=-1 vendor/bin/phpunit --coverage-html=var/coverage --coverage-clover=var/coverage/clover.xml
4752
@php bin/coverage-checker.php var/coverage/clover.xml $(COVERAGE_THRESHOLD)
4853

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ In both cases, your controller code has to be [modified accordingly](https://sym
214214

215215
## References 📚
216216

217-
* [PHPStan 2.0 Released With Level 10 and Elephpants!](https://phpstan.org/blog/phpstan-2-0-released-level-10-elephpants) (phpstan.org)
218-
* [A better ADR pattern for your Symfony controllers](https://www.strangebuzz.com/en/blog/a-better-adr-pattern-for-your-symfony-controllers) (strangebuzz.com)
217+
* [A better ADR pattern for your Symfony controllers](https://www.strangebuzz.com/en/blog/a-better-adr-pattern-for-your-symfony-controllers) (strangebuzz.com) (coming soon)
219218
* [My Taskfile configuration for Symfony](https://jmsche.fr/en/blog/my-taskfile-configuration-for-symfony) (jmsche.fr)
220219
* [You should be using PHPStans bleeding edge](https://backendtea.com/post/use-phpstan-bleeding-edge/) (backendtea.com)
221220
* [A Good Naming Convention for Routes, Controllers and Templates?](https://jolicode.com/blog/a-good-naming-convention-for-routes-controllers-and-templates) (jolicode.com)

castor.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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

2121
function 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'])]
97107
function 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
107118
function 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');

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"ext-libxml": "*",
2222
"ext-simplexml": "*",
2323
"ext-xml": "*",
24+
"laravel/serializable-closure": "^1.3",
2425
"league/commonmark": "^2.4",
2526
"symfony/asset": "~7.1.0",
2627
"symfony/asset-mapper": "~7.1.0",
@@ -44,10 +45,12 @@
4445
"symfony/yaml": "~7.1.0",
4546
"twig/extra-bundle": "^3.0",
4647
"twig/markdown-extra": "^3.7",
47-
"twig/twig": "^3.0"
48+
"twig/twig": "^3.0",
49+
"wouterj/eloquent-bundle": "^2.7"
4850
},
4951
"require-dev": {
5052
"bamarni/composer-bin-plugin": "^1.8",
53+
"fakerphp/faker": "^1.23",
5154
"phpstan/extension-installer": "^1.3",
5255
"phpstan/phpstan-symfony": "^2.0",
5356
"phpunit/phpunit": "^11.0",

0 commit comments

Comments
 (0)