Skip to content

Commit

Permalink
bump to phpunit 11.5, remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
tacman committed Oct 15, 2024
1 parent d9c5b0a commit 9968466
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"escapestudios/symfony2-coding-standard": "^3.0",
"phpunit/phpunit": "^10.5",
"phpunit/phpunit": "^11.4",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.8"
"phpstan/phpstan": "^1.8",
"rector/rector": "^1.2"
},
"scripts": {
"test": "phpunit",
Expand Down
6 changes: 5 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
->withPhpSets(php82: true)
->withPhpSets(php83: true)
->withSets([
PHPUnitSetList::PHPUNIT_110
])
->withRules([
AddVoidReturnTypeWhereNoReturnRector::class,
]);
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ public function testChoice(): void
// 4 times: firstName, form, and the two choices
$this->translator->expects($this->exactly(4))
->method('trans')
->will($this->returnCallback(fn($str) => $str.'-translated'));
->willReturnCallback(fn($str) => $str.'-translated');

$resolver = new Resolver();
$resolver->setTransformer('choice', new Transformer\ChoiceTransformer($this->translator, null));
$transformer = new CompoundTransformer($this->translator, $resolver);
$transformed = $transformer->transform($form);
$this->assertTrue(is_array($transformed));
$this->assertArrayHasKey('enum_titles', $transformed['properties']['firstName']);
$this->assertArrayHasKey('enum_titles', $transformed['properties']['firstName']['options']);
$this->assertEquals(['a-translated', 'b-translated'], $transformed['properties']['firstName']['enum_titles']);
Expand All @@ -69,13 +68,12 @@ public function testChoiceExpanded(): void
// 4 times: firstName, form, and the two choices
$this->translator->expects($this->exactly(4))
->method('trans')
->will($this->returnCallback(fn($str) => $str.'-translated'));
->willReturnCallback(fn($str) => $str.'-translated');

$resolver = new Resolver();
$resolver->setTransformer('choice', new Transformer\ChoiceTransformer($this->translator, null));
$transformer = new CompoundTransformer($this->translator, $resolver);
$transformed = $transformer->transform($form);
$this->assertTrue(is_array($transformed));
$this->assertArrayHasKey('enum_titles', $transformed['properties']['firstName']);
$this->assertArrayHasKey('enum_titles', $transformed['properties']['firstName']['options']);
$this->assertEquals(['a-translated', 'b-translated'], $transformed['properties']['firstName']['enum_titles']);
Expand All @@ -102,7 +100,6 @@ public function testChoiceMultiple(): void
$resolver->setTransformer('choice', new Transformer\ChoiceTransformer($this->translator, null));
$transformer = new CompoundTransformer($this->translator, $resolver);
$transformed = $transformer->transform($form);
$this->assertTrue(is_array($transformed));
$this->assertArrayHasKey('items', $transformed['properties']['firstName']);
$this->assertEquals('array', $transformed['properties']['firstName']['type']);
$this->assertArrayNotHasKey('widget', $transformed['properties']['firstName']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function testRequired(): void
$transformer = new CompoundTransformer($this->translator, $resolver);
$transformed = $transformer->transform($form);

$this->assertTrue(is_array($transformed));
$this->assertArrayHasKey('required', $transformed);
$this->assertTrue(is_array($transformed['required']));
$this->assertContains('firstName', $transformed['required']);
Expand All @@ -56,11 +55,10 @@ public function testDescription(): void
$resolver->setTransformer('text', new StringTransformer($this->translator));

$this->translator->method('trans')
->will($this->returnCallback(fn($description) => $description));
->willReturnCallback(fn($description) => $description);
$transformer = new CompoundTransformer($this->translator, $resolver);
$transformed = $transformer->transform($form);

$this->assertTrue(is_array($transformed));
$this->assertArrayHasKey('description', $transformed['properties']['firstName']);
$this->assertSame($description, $transformed['properties']['firstName']['description']);
}
Expand All @@ -79,11 +77,10 @@ public function testDescriptionFromFormHelp(): void
$resolver = new Resolver();
$resolver->setTransformer('text', new StringTransformer($this->translator));
$this->translator->method('trans')
->will($this->returnCallback(fn($description) => $description));
->willReturnCallback(fn($description) => $description);
$transformer = new CompoundTransformer($this->translator, $resolver);
$transformed = $transformer->transform($form);

$this->assertTrue(is_array($transformed));
$this->assertArrayHasKey('description', $transformed['properties']['firstName']);
$this->assertSame($description, $transformed['properties']['firstName']['description']);
}
Expand All @@ -106,10 +103,9 @@ public function testDescriptionFromFormHelpOverriddenByLiformDescription(): void
$resolver->setTransformer('text', new StringTransformer($this->translator));
$transformer = new CompoundTransformer($this->translator, $resolver);
$this->translator->method('trans')
->will($this->returnCallback(fn($description) => $description));
->willReturnCallback(fn($description) => $description);
$transformed = $transformer->transform($form);

$this->assertTrue(is_array($transformed));
$this->assertArrayHasKey('description', $transformed['properties']['firstName']);
$this->assertSame($description, $transformed['properties']['firstName']['description']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function testPattern(): void
$resolver->setTransformer('text', new StringTransformer($this->translator));
$transformer = new CompoundTransformer($this->translator, $resolver);
$transformed = $transformer->transform($form);
$this->assertTrue(is_array($transformed));
$this->assertEquals('.{5,}', $transformed['properties']['firstName']['pattern']);
}
}

0 comments on commit 9968466

Please sign in to comment.