Skip to content

Commit

Permalink
test: modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Oct 3, 2024
1 parent b099386 commit 250b2f4
Show file tree
Hide file tree
Showing 26 changed files with 463 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
APP_ENV=test
PHP=php
SYMFONY=symfony
COMPOSER=composer

# use .env.local to override, example:

# PHP with xdebug:
#PHP=php -dxdebug.start_with_request=yes -dxdebug.mode=debug

# PHP using docker and xdebug:
#PHP=docker run -it --rm --user $$(id -u):$$(id -g) -v "$$PWD":/usr/src/myapp -w /usr/src/myapp php:8.4.0beta5-cli php -dxdebug.start_with_request=yes -dxdebug.mode=debug
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
composer.lock
vendor/
vendor
.phpunit.cache
tools
.php-cs-fixer.cache
var
rector.log
.env.local
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
include .env
-include .env.local

export APP_ENV

.PHONY: all
all: test

Expand All @@ -10,17 +15,17 @@ test: composer-dump composer-validate phpstan psalm phpunit

.PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse
$(PHP) vendor/bin/phpstan analyse

.PHONY: psalm
psalm:
vendor/bin/psalm
$(PHP) vendor/bin/psalm

.PHONY: phpunit
phpunit:
$(eval c ?=)
rm -rf tests/var
vendor/bin/phpunit $(c)
$(PHP) vendor/bin/phpunit $(c)

.PHONY: composer-dump
composer-dump:
Expand All @@ -32,7 +37,7 @@ composer-validate:

.PHONY: php-cs-fixer
php-cs-fixer: tools/php-cs-fixer
$< fix --config=.php-cs-fixer.dist.php --verbose --allow-risky=yes
$(PHP) $< fix --config=.php-cs-fixer.dist.php --verbose --allow-risky=yes

.PHONY: tools/php-cs-fixer
tools/php-cs-fixer:
Expand Down Expand Up @@ -62,3 +67,11 @@ monorepo-release-%:
git switch -c release/$*
git add .
git commit -m "release: $*"

.PHONY: serve
serve:
$(PHP) tests/bin/console cache:clear
$(PHP) tests/bin/console importmap:install
$(PHP) tests/bin/console asset-map:compile
$(PHP) tests/bin/console asset:install tests/public/
cd tests && sh -c "$(SYMFONY) server:start --document-root=public"
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"league/mime-type-detection": "^1.0.0",
"maennchen/zipstream-php": "^3.1",
"nyholm/psr7": "^1.8",
"oneup/uploader-bundle": "^4.0",
"oneup/uploader-bundle": "^5.0",
"php": "^8.1",
"php-http/discovery": "^1.15",
"psr/container": "^2.0",
"psr/http-factory-implementation": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"rekalogika/direct-property-access": "^1.1.2 || ^1.2",
"rekalogika/doctrine-collections-decorator": "^2.3",
"rekalogika/doctrine-collections-decorator": "^2.0",
"rekalogika/reconstitutor": "^1.3.2 || ^1.4",
"rekalogika/temporary-url-bundle": "^1.3",
"symfony/config": "^6.2 || ^7.0",
Expand Down Expand Up @@ -61,18 +61,25 @@
"psalm/plugin-mockery": "^1.1",
"psalm/plugin-phpunit": "^0.19.0",
"rector/rector": "^1.2",
"symfony/asset": "^6.2 || ^7.0",
"symfony/asset-mapper": "^6.2 || ^7.0",
"symfony/console": "^6.2 || ^7.0",
"symfony/debug-bundle": "^6.2 || ^7.0",
"symfony/dotenv": "^6.2 || ^7.0",
"symfony/framework-bundle": "^6.2 || ^7.0",
"symfony/http-client": "^6.2 || ^7.0",
"symfony/maker-bundle": "^1.55",
"symfony/monolog-bundle": "^3.0",
"symfony/phpunit-bridge": "^6.3 || ^7.0",
"symfony/property-info": "^6.2 || ^7.0",
"symfony/routing": "^6.2 || ^7.0",
"symfony/runtime": "^6.2 || ^7.0",
"symfony/twig-bundle": "^6.2 || ^7.0",
"symfony/ux-turbo": "^2.20",
"symfony/web-profiler-bundle": "^6.2 || ^7.0",
"symfony/yaml": "^6.2 || ^7.0",
"symplify/monorepo-builder": "^11.2.20 || ^11.3",
"twig/extra-bundle": "^2.12|^3.0",
"vimeo/psalm": "^5.26"
},
"replace": {
Expand Down
49 changes: 48 additions & 1 deletion packages/file-filepond/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,54 @@
}
},
"importmap": {
"@hotwired/stimulus": "^3.0"
"@hotwired/stimulus": "^3.0",
"filepond": "^4.31.3",
"filepond/dist/filepond.min.css": "^4.31.3",
"filepond-plugin-file-encode": "^2.1.11",
"filepond-plugin-file-metadata": "^1.0.8",
"filepond-plugin-file-poster": "^2.5.1",
"filepond-plugin-file-poster/dist/filepond-plugin-file-poster.css": "^2.5.1",
"filepond-plugin-file-validate-size": "^2.2.8",
"filepond-plugin-file-validate-type": "^1.2.8",
"filepond-plugin-image-crop": "^2.0.6",
"filepond-plugin-image-edit": "^1.6.3",
"filepond-plugin-image-edit/dist/filepond-plugin-image-edit.css": "^1.6.3",
"filepond-plugin-image-exif-orientation": "^1.0.11",
"filepond-plugin-image-preview": "^4.6.11",
"filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css": "^4.6.11",
"filepond-plugin-image-resize": "^2.0.10",
"filepond-plugin-image-transform": "^3.8.7",
"filepond-plugin-image-validate-size": "^1.2.7",
"filepond/locale/ar-ar.js": "^4.31.3",
"filepond/locale/cs-cz.js": "^4.31.3",
"filepond/locale/da-dk.js": "^4.31.3",
"filepond/locale/de-de.js": "^4.31.3",
"filepond/locale/el-el.js": "^4.31.3",
"filepond/locale/en-en.js": "^4.31.3",
"filepond/locale/es-es.js": "^4.31.3",
"filepond/locale/fa_ir.js": "^4.31.3",
"filepond/locale/fi-fi.js": "^4.31.3",
"filepond/locale/fr-fr.js": "^4.31.3",
"filepond/locale/he-he.js": "^4.31.3",
"filepond/locale/hr-hr.js": "^4.31.3",
"filepond/locale/hu-hu.js": "^4.31.3",
"filepond/locale/id-id.js": "^4.31.3",
"filepond/locale/it-it.js": "^4.31.3",
"filepond/locale/ja-ja.js": "^4.31.3",
"filepond/locale/lt-lt.js": "^4.31.3",
"filepond/locale/nl-nl.js": "^4.31.3",
"filepond/locale/no_nb.js": "^4.31.3",
"filepond/locale/pl-pl.js": "^4.31.3",
"filepond/locale/pt-br.js": "^4.31.3",
"filepond/locale/ro-ro.js": "^4.31.3",
"filepond/locale/ru-ru.js": "^4.31.3",
"filepond/locale/sk-sk.js": "^4.31.3",
"filepond/locale/sv_se.js": "^4.31.3",
"filepond/locale/tr-tr.js": "^4.31.3",
"filepond/locale/uk-ua.js": "^4.31.3",
"filepond/locale/vi-vi.js": "^4.31.3",
"filepond/locale/zh-cn.js": "^4.31.3",
"filepond/locale/zh-tw.js": "^4.31.3"
}
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/file-oneup-uploader-bridge/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
},
"require": {
"oneup/uploader-bundle": "^4.0",
"oneup/uploader-bundle": "^5.0",
"rekalogika/file-contracts": "^1.10.1",
"rekalogika/file": "^1.10.1"
},
Expand Down
10 changes: 10 additions & 0 deletions tests/assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import './bootstrap.js';
/*
* Welcome to your app's main JavaScript file!
*
* This file will be included onto the page via the importmap() Twig function,
* which should already be in your base.html.twig.
*/
import './styles/app.css';

console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');
5 changes: 5 additions & 0 deletions tests/assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { startStimulusApp } from '@symfony/stimulus-bundle';

const app = startStimulusApp();
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
4 changes: 4 additions & 0 deletions tests/assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"controllers": {},
"entrypoints": []
}
16 changes: 16 additions & 0 deletions tests/assets/controllers/hello_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Controller } from '@hotwired/stimulus';

/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
}
}
3 changes: 3 additions & 0 deletions tests/assets/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: skyblue;
}
5 changes: 5 additions & 0 deletions tests/config/packages/asset_mapper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework:
asset_mapper:
# The paths to make available to the asset mapper.
paths:
- assets/
3 changes: 3 additions & 0 deletions tests/config/packages/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
router:
utf8: true
4 changes: 4 additions & 0 deletions tests/config/packages/translation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
default_locale: en
translator:
default_path: '%kernel.project_dir%/translations'
2 changes: 2 additions & 0 deletions tests/config/packages/twig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
twig:
form_themes: ['bootstrap_5_horizontal_layout.html.twig']
11 changes: 11 additions & 0 deletions tests/config/packages/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
web_profiler:
toolbar: true
intercept_redirects: false

framework:
profiler:
enabled: true
collect: true
only_exceptions: false
collect_serializer_data: true
only_main_requests: false
5 changes: 5 additions & 0 deletions tests/config/routes/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
resource:
path: '../../src/App/Controller/'
namespace: 'Rekalogika\File\Tests\App\Controller'
type: attribute
7 changes: 7 additions & 0 deletions tests/config/routes/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
web_profiler_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt

web_profiler_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
27 changes: 27 additions & 0 deletions tests/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/*
* This file is part of rekalogika/mapper package.
*
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();

$services->defaults()
->autowire()
->autoconfigure()
->public();

$services
->load('Rekalogika\\File\\Tests\\App\\', '../src/App/*');

};
Loading

0 comments on commit 250b2f4

Please sign in to comment.