Skip to content

Commit

Permalink
test: modernization (#55)
Browse files Browse the repository at this point in the history
* test: modernization

* enable runtime

* fix phpstan

* namespace

* fix

* phpstan

* updates
  • Loading branch information
priyadi authored Oct 3, 2024
1 parent 1b38d8a commit b099386
Show file tree
Hide file tree
Showing 65 changed files with 337 additions and 262 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_ENV=test
6 changes: 4 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/packages')
->in(__DIR__ . '/tests')
->in(__DIR__ . '/tests/src')

;

$config = new PhpCsFixer\Config();
return $config->setRules([
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
'fully_qualified_strict_types' => true,
'fully_qualified_strict_types' => [
'import_symbols' => true,
],
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.11.0

* test: modernization

## 1.10.2

* chore: cleanup `composer.json`
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ psalm:
.PHONY: phpunit
phpunit:
$(eval c ?=)
rm -rf tests/var
vendor/bin/phpunit $(c)

.PHONY: composer-dump
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"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.0",
"rekalogika/doctrine-collections-decorator": "^2.3",
"rekalogika/reconstitutor": "^1.3.2 || ^1.4",
"rekalogika/temporary-url-bundle": "^1.3",
"symfony/config": "^6.2 || ^7.0",
Expand All @@ -53,7 +53,7 @@
"ekino/phpstan-banned-code": "^2.1",
"league/flysystem-memory": "^3.16",
"mockery/mockery": "^1.6",
"phpstan/phpstan": "1.12.2 || ^1.12.4 || ^1.13",
"phpstan/phpstan": "^1.12.5 || ^1.13",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
Expand All @@ -63,11 +63,14 @@
"rector/rector": "^1.2",
"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/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/yaml": "^6.2 || ^7.0",
"symplify/monorepo-builder": "^11.2.20 || ^11.3",
"vimeo/psalm": "^5.26"
Expand Down Expand Up @@ -115,12 +118,13 @@
},
"autoload-dev": {
"psr-4": {
"Rekalogika\\File\\Tests\\": "tests/"
"Rekalogika\\File\\Tests\\": "tests/src/"
}
},
"config": {
"allow-plugins": {
"php-http/discovery": true
"php-http/discovery": true,
"symfony/runtime": true
}
}
}
6 changes: 3 additions & 3 deletions packages/file-bundle/config/tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
// add test aliases
$serviceIds = TestKernel::getServiceIds();

foreach ($serviceIds as $serviceId) {
$services->alias('test.' . $serviceId, $serviceId)->public();
}
// foreach ($serviceIds as $serviceId) {
// $services->set($serviceId)->public();
// }

// filesystem for testing
$services->set('test.filesystem', FilesystemOperator::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public function getPath(): string
#[\Override]
public function getPathInfo($class = null): ?\SplFileInfo
{
// @phpstan-ignore return.type
return $this->getHttpFoundationFile()->getPathInfo($class);
}

Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
level: max
paths:
- packages
- tests
- tests/src
# exceptions:
# check:
# missingCheckedExceptionInThrows: true
Expand Down
10 changes: 9 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@
failOnWarning="false"
cacheDirectory=".phpunit.cache"
beStrictAboutCoverageMetadata="true">

<php>
<server
name="KERNEL_CLASS"
value="Rekalogika\File\Tests\TestKernel" />
</php>

<testsuites>
<testsuite name="default">
<directory>tests</directory>
<directory>tests/src/ </directory>
</testsuite>
</testsuites>

<source>
<include>
<directory suffix=".php">packages</directory>
Expand Down
10 changes: 5 additions & 5 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<projectFiles>
<directory name="packages" />
<directory name="tests" />
<directory name="tests/src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
Expand All @@ -21,8 +21,8 @@
<errorLevel type="suppress">
<directory name="packages/file-symfony-bridge/src/Constraints/" />
<file name="packages/file-symfony-bridge/src/HttpFoundation/FileResponse.php" />
<file name="tests/Model/EntityWithMandatoryFile.php" />
<file name="tests/Model/EntityExtendingAbstractFile.php" />
<file name="tests/src/Tests/Model/EntityWithMandatoryFile.php" />
<file name="tests/src/Tests/Model/EntityExtendingAbstractFile.php" />
<file name="packages/file-zip/src/ZipDirectory.php" />
</errorLevel>
</PropertyNotSetInConstructor>
Expand All @@ -34,8 +34,8 @@
</RedundantPropertyInitializationCheck>
<MissingConstructor>
<errorLevel type="suppress">
<file name="tests/File/FileRepositoryTest.php" />
<file name="tests/Model/EntityWithDifferentFileProperties.php" />
<file name="tests/src/Tests/File/FileRepositoryTest.php" />
<file name="tests/src/Tests/Model/EntityWithDifferentFileProperties.php" />
</errorLevel>
</MissingConstructor>
<UndefinedMethod>
Expand Down
43 changes: 0 additions & 43 deletions tests/FileBundle/IntegrationTest.php

This file was deleted.

68 changes: 0 additions & 68 deletions tests/FileServer/TemporaryUrlTest.php

This file was deleted.

29 changes: 29 additions & 0 deletions tests/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?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.
*/

namespace Rekalogika\Mapper\Tests;

use Rekalogika\File\Tests\TestKernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

require_once dirname(__DIR__).'/../vendor/autoload_runtime.php';

return function (array $context) {
$env = $context['APP_ENV'] ?? 'test';
assert(is_string($env));

$kernel = new TestKernel($env, (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
4 changes: 4 additions & 0 deletions tests/config/packages/debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"
20 changes: 20 additions & 0 deletions tests/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
doctrine:
dbal:
driver: pdo_sqlite
memory: true
charset: UTF8

orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
controller_resolver:
auto_mapping: false
enable_lazy_ghost_objects: true
report_fields_where_declared: true
mappings:
App:
is_bundle: false
type: attribute
dir: "%kernel.project_dir%/src/Entity"
prefix: 'Rekalogika\File\Tests\Entity'
alias: App
16 changes: 16 additions & 0 deletions tests/config/packages/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
kernel.secret: test

framework:
test: true
http_method_override: false
handle_all_throwables: true
php_errors:
log: true
validation:
email_validation_mode: html5
http_client:
enabled: true
max_host_connections: 1
default_options:
timeout: 10
Loading

0 comments on commit b099386

Please sign in to comment.