Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature branch: use Doctrine DBAL #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ APP_SECRET=
# To test the production environment, run "make go-prod" or "castor symfony:go-prod"

# To come back to the development environment, run "make go-dev" or "castor symfony:go-dev"

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
###< doctrine/doctrine-bundle ###
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ go-dev: ## Switch to the development environment
warmup: ## Warmup the dev cache for the static analysis
@bin/console c:w --env=dev

purge: ## Purge all Symfony cache and logs
purge: ## Purge all Symfony variable data
@rm -rf ./var/cache/* ./var/logs/* ./var/coverage/*

load-fixtures: ## Reset migrations and load the database fixtures
@rm -f ./var/data.db
@bin/console doctrine:migration:migrate --env=dev --no-interaction
@bin/console app:load-fixtures --env=dev --no-interaction


## —— Tests ✅ —————————————————————————————————————————————————————————————————
test: ## Run all PHPUnit tests
@vendor/bin/phpunit

coverage: ## Generate the HTML PHPUnit code coverage report (stored in var/coverage)
coverage: purge
coverage: purge load-fixtures
@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
@php bin/coverage-checker.php var/coverage/clover.xml $(COVERAGE_THRESHOLD)

Expand Down
15 changes: 15 additions & 0 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,23 @@ function purge(): void
success(exit_code('rm -rf ./var/cache/* ./var/logs/* ./var/coverage/*'));
}

#[AsTask(namespace: 'app', description: 'Load the database fixtures', aliases: ['load-fixtures'])]
function loadFixures(): void
{
title('app:load-fixtures');
io()->note('Resetting db...');
success(exit_code('rm -f ./var/data.db'));
io()->note('Running db migrations...');
success(exit_code('bin/console doctrine:migration:migrate --no-interaction'));
io()->note('Load fixtures...');
success(exit_code('bin/console app:load-fixtures --no-interaction'));
}

#[AsTask(name: 'all', namespace: 'test', description: 'Run all PHPUnit tests', aliases: ['test'])]
function test_all(): int
{
title('test:all');
loadFixures();
$ec = exit_code(__DIR__.'/vendor/bin/phpunit');
io()->writeln('');

Expand All @@ -110,6 +123,7 @@ function test_all(): int
function coverage(): int
{
title('test:coverage');
loadFixures();
$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',
context: context()->withEnvironment(['XDEBUG_MODE' => 'coverage'])
);
Expand Down Expand Up @@ -241,6 +255,7 @@ function ci(): void
{
title('ci:all');
purge();
loadFixures();
io()->section('Coverage');
coverage();
io()->section('Lints');
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"doctrine/dbal": "^4.0",
"doctrine/doctrine-bundle": "^2.13",
"doctrine/doctrine-migrations-bundle": "^3.3",
"league/commonmark": "^2.4",
"symfony/asset": "~7.2.0",
"symfony/asset-mapper": "~7.2.0",
Expand Down
Loading
Loading