Skip to content

Commit d6a0c59

Browse files
authored
Clean the tests suite (#243)
2 parents 3a6627a + 297eb40 commit d6a0c59

File tree

117 files changed

+1478
-1352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1478
-1352
lines changed

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'no_trailing_comma_in_singleline' => false,
2525
'function_declaration' => ['trailing_comma_single_line' => true],
2626
'phpdoc_to_comment' => ['allow_before_return_statement' => true],
27+
'psr_autoloading' => false, // Does not work well with "map.php" files in tests
2728
PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true,
2829
])
2930
->setFinder($finder)

castor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function qa_cs_check()
1515
]);
1616
}
1717

18-
#[AsTask('cs:fix', namespace: 'qa', description: 'Fix all coding standards')]
18+
#[AsTask('cs:fix', namespace: 'qa', description: 'Fix all coding standards', aliases: ['cs'])]
1919
function qa_cs_fix()
2020
{
21-
php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php'], '3.50', [
21+
php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php', '-v'], '3.50', [
2222
'kubawerlos/php-cs-fixer-custom-fixers' => '^3.21',
2323
]);
2424
}
2525

26-
#[AsTask('phpstan', namespace: 'qa', description: 'Run PHPStan for static analysis')]
26+
#[AsTask('phpstan', namespace: 'qa', description: 'Run PHPStan for static analysis', aliases: ['phpstan'])]
2727
function qa_phpstan(bool $generateBaseline = false)
2828
{
2929
$params = ['analyse', '--configuration', __DIR__ . '/phpstan.neon', '--memory-limit=-1', '-v'];

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"phpunit/phpunit": "^9.0",
3838
"symfony/browser-kit": "^6.4 || ^7.0",
3939
"symfony/console": "^6.4 || ^7.0",
40+
"symfony/finder": "^6.4 || ^7.2",
4041
"symfony/filesystem": "^6.4 || ^7.0",
4142
"symfony/framework-bundle": "*",
4243
"symfony/http-client": "^6.4 || ^7.0",
@@ -45,6 +46,7 @@
4546
"symfony/stopwatch": "^6.4 || ^7.0",
4647
"symfony/twig-bundle": "^6.4 || ^7.0",
4748
"symfony/uid": "^6.4 || ^7.0",
49+
"symfony/var-dumper": "^6.4 || ^7.2",
4850
"symfony/web-profiler-bundle": "^6.4 || ^7.0",
4951
"symfony/yaml": "^6.4 || ^7.0",
5052
"willdurand/negotiation": "^3.0"
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,16 @@
88
use AutoMapper\Configuration;
99
use AutoMapper\ConstructorStrategy;
1010
use AutoMapper\Symfony\ExpressionLanguageProvider;
11-
use PHPUnit\Framework\TestCase;
1211
use Symfony\Component\EventDispatcher\EventDispatcher;
1312
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1413
use Symfony\Component\Filesystem\Filesystem;
1514

1615
/**
1716
* @author Baptiste Leduc <[email protected]>
1817
*/
19-
abstract class AutoMapperBaseTest extends TestCase
18+
class AutoMapperBuilder
2019
{
21-
protected AutoMapper $autoMapper;
22-
23-
protected function setUp(): void
24-
{
25-
unset($this->autoMapper);
26-
$this->buildAutoMapper();
27-
}
28-
29-
protected function buildAutoMapper(
20+
public static function buildAutoMapper(
3021
bool $allowReadOnlyTargetToPopulate = false,
3122
bool $mapPrivatePropertiesAndMethod = false,
3223
ConstructorStrategy $constructorStrategy = ConstructorStrategy::AUTO,
@@ -53,7 +44,7 @@ classPrefix: $classPrefix,
5344
allowReadOnlyTargetToPopulate: $allowReadOnlyTargetToPopulate,
5445
);
5546

56-
return $this->autoMapper = AutoMapper::create(
47+
return AutoMapper::create(
5748
$configuration,
5849
cacheDirectory: __DIR__ . '/cache/',
5950
transformerFactories: $transformerFactories,

tests/AutoMapperMapToTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* @author Joel Wurtz <[email protected]>
2222
*/
23-
class AutoMapperMapToTest extends AutoMapperBaseTest
23+
class AutoMapperMapToTest extends AutoMapperTestCase
2424
{
2525
public function testMapTo()
2626
{
@@ -40,7 +40,7 @@ public function testMapToArray()
4040
'transformerWithDependency' => fn () => fn () => new TransformerWithDependency(new FooDependency()),
4141
]));
4242

43-
$this->buildAutoMapper(propertyTransformers: [new TransformerWithDependency(new FooDependency())], expressionLanguageProvider: $expressionLanguageProvider);
43+
$this->autoMapper = AutoMapperBuilder::buildAutoMapper(propertyTransformers: [new TransformerWithDependency(new FooDependency())], expressionLanguageProvider: $expressionLanguageProvider);
4444

4545
$foo = new FooMapTo('foo');
4646
$bar = $this->autoMapper->map($foo, 'array');
@@ -86,7 +86,7 @@ public function testMapToArrayGroups()
8686
'transformerWithDependency' => fn () => fn () => new TransformerWithDependency(new FooDependency()),
8787
]));
8888

89-
$this->buildAutoMapper(propertyTransformers: [new TransformerWithDependency(new FooDependency())], expressionLanguageProvider: $expressionLanguageProvider);
89+
$this->autoMapper = AutoMapperBuilder::buildAutoMapper(propertyTransformers: [new TransformerWithDependency(new FooDependency())], expressionLanguageProvider: $expressionLanguageProvider);
9090

9191
$foo = new FooMapTo('foo');
9292
$bar = $this->autoMapper->map($foo, 'array');

0 commit comments

Comments
 (0)