Skip to content

Commit

Permalink
Add resource package on test application
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Jul 1, 2024
1 parent 98629ec commit 68ebb46
Show file tree
Hide file tree
Showing 16 changed files with 213 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@
APP_ENV=dev
APP_SECRET=28de35e787e86cb435f0312627623283
###< symfony/framework-bundle ###

###> 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="postgresql://app:[email protected]:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###
11 changes: 10 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,14 @@ jobs:
- name: Run PHPUnit
run: vendor/bin/phpunit

- name: "Restrict packages' versions"
run: |
(cd src/TwigHooks/ && composer global config --no-plugins allow-plugins.symfony/flex true)
(cd src/TwigHooks/ && composer global require --no-progress --no-scripts --no-plugins "symfony/flex")
(cd src/TwigHooks/ && composer config extra.symfony.require "${{ matrix.symfony }}")
- name: "Install dependencies (Twig Hooks)"
run: (cd src/TwigHooks/ && composer update --no-interaction --no-scripts)

- name: Run PHPUnit (Twig Hooks)
run: vendor/bin/phpunit -c src/TwigHooks/phpunit.xml.dist
run: (cd src/TwigHooks/ && vendor/bin/phpunit)
Empty file added app/Entity/.gitignore
Empty file.
Empty file added app/Repository/.gitignore
Empty file.
6 changes: 6 additions & 0 deletions compose.override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
###> doctrine/doctrine-bundle ###
database:
ports:
- "5432:5432"
###< doctrine/doctrine-bundle ###
19 changes: 19 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
###> doctrine/doctrine-bundle ###
database:
image: postgres:${POSTGRES_VERSION:-16}-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-sylius_stack}
# You should definitely change the password in production
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-sylius_stack}
POSTGRES_USER: ${POSTGRES_USER:-sylius_stack}
volumes:
- database_data:/var/lib/postgresql/data:rw
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/db/data:/var/lib/postgresql/data:rw
###< doctrine/doctrine-bundle ###

volumes:
###> doctrine/doctrine-bundle ###
database_data:
###< doctrine/doctrine-bundle ###
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
],
"require": {
"php": "^8.1",
"doctrine/dbal": "^3",
"doctrine/doctrine-bundle": "^2.12",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^2.0",
"laminas/laminas-stdlib": "^3.18",
"sylius/resource-bundle": "dev-symfony-7",
"symfony/config": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/expression-language": "^6.4 || ^7.0",
Expand Down
5 changes: 5 additions & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true],
winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
];
50 changes: 50 additions & 0 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'

# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '16'

profiling_collect_backtrace: '%kernel.debug%'
use_savepoints: true
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
type: attribute
is_bundle: false
dir: '%kernel.project_dir%/app/Entity'
prefix: 'App\Entity'
alias: App

when@test:
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname_suffix: '_test%env(default::TEST_TOKEN)%'

when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool

framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
6 changes: 6 additions & 0 deletions config/packages/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doctrine_migrations:
migrations_paths:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/migrations'
enable_profiler: false
15 changes: 15 additions & 0 deletions config/packages/sylius_resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# @see https://github.com/Sylius/SyliusResourceBundle/blob/master/docs/index.md
sylius_resource:
# Override default settings
#settings:

# Configure the mapping for your resources
mapping:
paths:
- '%kernel.project_dir%/app/Entity'

# Configure your resources
resources:
#app.book:
#classes:
#model: App\Entity\Book
11 changes: 11 additions & 0 deletions config/packages/validator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
framework:
validation:
# Enables validator auto-mapping support.
# For instance, basic validation constraints will be inferred from Doctrine's metadata.
#auto_mapping:
# App\Entity\: []

when@test:
framework:
validation:
not_compromised_password: false
7 changes: 7 additions & 0 deletions config/routes/sylius_resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sylius_crud_routes:
resource: 'sylius.routing.loader.crud_routes_attributes'
type: service

sylius_routes:
resource: 'sylius.routing.loader.routes_attributes'
type: service
Empty file added migrations/.gitignore
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ final class HookableTwigComponentTest extends KernelTestCase
{
public function testItRendersHookableLiveComponentWithUsingTwigHooks(): void
{
self::bootKernel();

$this->assertSame(
<<<EXPECTED
<!-- BEGIN HOOK | name: "hookable_twig_component" -->
Expand Down
67 changes: 67 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
{
"babdev/pagerfanta-bundle": {
"version": "v4.4.0"
},
"doctrine/annotations": {
"version": "2.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.10",
"ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05"
}
},
"doctrine/doctrine-bundle": {
"version": "2.12",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.10",
"ref": "c170ded8fc587d6bd670550c43dafcf093762245"
},
"files": [
"config/packages/doctrine.yaml",
"src/Entity/.gitignore",
"src/Repository/.gitignore"
]
},
"doctrine/doctrine-migrations-bundle": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.1",
"ref": "1d01ec03c6ecbd67c3375c5478c9a423ae5d6a33"
},
"files": [
"config/packages/doctrine_migrations.yaml",
"migrations/.gitignore"
]
},
"phpstan/phpstan": {
"version": "1.10",
"recipe": {
Expand All @@ -22,6 +61,19 @@
"tests/bootstrap.php"
]
},
"sylius/resource-bundle": {
"version": "1.10",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "1.9",
"ref": "ee21c1fc90778f4b01c20e72c320cc34f8839c1e"
},
"files": [
"config/packages/sylius_resource.yaml",
"config/routes/sylius_resource.yaml"
]
},
"symfony/console": {
"version": "5.4",
"recipe": {
Expand Down Expand Up @@ -131,6 +183,18 @@
"symfony/ux-twig-component": {
"version": "v2.12.0"
},
"symfony/validator": {
"version": "7.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "7.0",
"ref": "8c1c4e28d26a124b0bb273f537ca8ce443472bfd"
},
"files": [
"config/packages/validator.yaml"
]
},
"symfony/web-profiler-bundle": {
"version": "6.3",
"recipe": {
Expand All @@ -143,5 +207,8 @@
"config/packages/web_profiler.yaml",
"config/routes/web_profiler.yaml"
]
},
"winzou/state-machine-bundle": {
"version": "v0.6.2"
}
}

0 comments on commit 68ebb46

Please sign in to comment.