Skip to content

Commit

Permalink
Merge 4.x into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI authored Nov 26, 2023
2 parents c649e6c + d327aa0 commit 2a219a0
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [4.29.0](https://github.com/sonata-project/SonataAdminBundle/compare/4.28.1...4.29.0) - 2023-11-25
### Added
- [[#8127](https://github.com/sonata-project/SonataAdminBundle/pull/8127)] Symfony 7 support ([@VincentLanglet](https://github.com/VincentLanglet))

## [4.28.1](https://github.com/sonata-project/SonataAdminBundle/compare/4.28.0...4.28.1) - 2023-11-20
### Fixed
- [[#8125](https://github.com/sonata-project/SonataAdminBundle/pull/8125)] Needing to submit form twice when using CRUDController::render() ([@AntoineRoue](https://github.com/AntoineRoue))
Expand Down
60 changes: 30 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,39 @@
"sonata-project/exporter": "^2.14 || ^3.1.1",
"sonata-project/form-extensions": "^1.15 || ^2.0",
"sonata-project/twig-extensions": "^1.4.1 || ^2.0",
"symfony/asset": "^5.4 || ^6.2",
"symfony/config": "^5.4 || ^6.2",
"symfony/console": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/doctrine-bridge": "^5.4 || ^6.2",
"symfony/event-dispatcher": "^5.4 || ^6.2",
"symfony/asset": "^5.4 || ^6.2 || ^7.0",
"symfony/config": "^5.4 || ^6.2 || ^7.0",
"symfony/console": "^5.4 || ^6.2 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.2 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.2 || ^7.0",
"symfony/event-dispatcher-contracts": "^2.0 || ^3.0",
"symfony/expression-language": "^5.4 || ^6.2",
"symfony/form": "^5.4 || ^6.2",
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/http-foundation": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/options-resolver": "^5.4 || ^6.2",
"symfony/property-access": "^5.4 || ^6.2",
"symfony/routing": "^5.4 || ^6.2",
"symfony/expression-language": "^5.4 || ^6.2 || ^7.0",
"symfony/form": "^5.4 || ^6.2 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.2 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.2 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.2 || ^7.0",
"symfony/property-access": "^5.4 || ^6.2 || ^7.0",
"symfony/routing": "^5.4 || ^6.2 || ^7.0",
"symfony/security-acl": "^3.1",
"symfony/security-bundle": "^5.4 || ^6.2",
"symfony/security-core": "^5.4 || ^6.2",
"symfony/security-csrf": "^5.4 || ^6.2",
"symfony/serializer": "^5.4 || ^6.2",
"symfony/string": "^5.4 || ^6.2",
"symfony/translation": "^5.4 || ^6.2",
"symfony/security-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/security-core": "^5.4 || ^6.2 || ^7.0",
"symfony/security-csrf": "^5.4 || ^6.2 || ^7.0",
"symfony/serializer": "^5.4 || ^6.2 || ^7.0",
"symfony/string": "^5.4 || ^6.2 || ^7.0",
"symfony/translation": "^5.4 || ^6.2 || ^7.0",
"symfony/translation-contracts": "^2.3 || ^3.0",
"symfony/twig-bridge": "^5.4 || ^6.2",
"symfony/twig-bundle": "^5.4 || ^6.2",
"symfony/validator": "^5.4 || ^6.2",
"symfony/twig-bridge": "^5.4 || ^6.2 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/validator": "^5.4 || ^6.2 || ^7.0",
"twig/string-extra": "^3.0",
"twig/twig": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"matthiasnoback/symfony-config-test": "^4.2 || ^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.2 || ^5.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand All @@ -80,12 +80,12 @@
"psalm/plugin-symfony": "^5.0",
"psr/event-dispatcher": "^1.0",
"rector/rector": "^0.18",
"symfony/browser-kit": "^5.4 || ^6.2",
"symfony/css-selector": "^5.4 || ^6.2",
"symfony/filesystem": "^5.4 || ^6.2",
"symfony/browser-kit": "^5.4 || ^6.2 || ^7.0",
"symfony/css-selector": "^5.4 || ^6.2 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.2 || ^7.0",
"symfony/maker-bundle": "^1.25",
"symfony/phpunit-bridge": "^6.2",
"symfony/yaml": "^5.4 || ^6.2",
"symfony/phpunit-bridge": "^6.2 || ^7.0",
"symfony/yaml": "^5.4 || ^6.2 || ^7.0",
"vimeo/psalm": "^5.8.0"
},
"suggest": {
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/Model/FilterData.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static function fromArray(array $data): self
if (isset($data['type'])) {
if (!\is_int($data['type']) && (!\is_string($data['type']) || !is_numeric($data['type']))) {
throw new \InvalidArgumentException(sprintf(
'The "type" parameter MUST be of type "integer" or "null", %s given.',
\is_object($data['type']) ? 'instance of "'.$data['type']::class.'"' : '"'.\gettype($data['type']).'"'
'The "type" parameter MUST be of type "integer" or "null", "%s" given.',
\gettype($data['type'])
));
}

Expand Down
3 changes: 1 addition & 2 deletions src/Form/Type/Filter/DateTimeRangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Sonata\AdminBundle\Form\Type\Operator\DateRangeOperatorType;
use Sonata\Form\Type\DateTimeRangeType as FormDateTimeRangeType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
Expand Down Expand Up @@ -46,7 +45,7 @@ public function configureOptions(OptionsResolver $resolver): void
'operator_type' => DateRangeOperatorType::class,
'field_type' => FormDateTimeRangeType::class,
'field_options' => [
'field_options' => ['date_format' => DateTimeType::HTML5_FORMAT],
'field_options' => [],
],
]);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Form/Type/Filter/DateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Sonata\AdminBundle\Form\Type\Operator\DateOperatorType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType as FormDateTimeType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
Expand Down Expand Up @@ -45,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefaults([
'operator_type' => DateOperatorType::class,
'field_type' => FormDateTimeType::class,
'field_options' => ['date_format' => DateType::HTML5_FORMAT],
'field_options' => [],
]);
}
}
2 changes: 1 addition & 1 deletion src/Route/RoutesCacheWarmUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function isOptional(): bool
/**
* @return string[]
*/
public function warmUp(string $cacheDir): array
public function warmUp(string $cacheDir, ?string $buildDir = null): array
{
foreach ($this->pool->getAdminServiceCodes() as $code) {
$this->cache->load($this->pool->getInstance($code));
Expand Down
4 changes: 2 additions & 2 deletions src/Security/Handler/AclSecurityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function __construct(
$this->superAdminRoles = [$superAdminRoles];
} else {
throw new \TypeError(sprintf(
'Argument 1 passed to "%s()" must be of type "array" or "string", %s given.',
'Argument 1 passed to "%s()" must be of type "array" or "string", "%s" given.',
__METHOD__,
\is_object($superAdminRoles) ? 'instance of "'.$superAdminRoles::class.'"' : '"'.\gettype($superAdminRoles).'"'
\gettype($superAdminRoles)
));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Security/Handler/RoleSecurityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function __construct(
$this->superAdminRoles = [$superAdminRoles];
} else {
throw new \TypeError(sprintf(
'Argument 1 passed to "%s()" must be of type "array" or "string", %s given.',
'Argument 1 passed to "%s()" must be of type "array" or "string", "%s" given.',
__METHOD__,
\is_object($superAdminRoles) ? 'instance of "'.$superAdminRoles::class.'"' : '"'.\gettype($superAdminRoles).'"'
\gettype($superAdminRoles)
));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Util/TraversableToCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public static function transform($value): Collection
}

throw new \TypeError(sprintf(
'Argument 1 passed to "%s()" must be an iterable, %s given.',
'Argument 1 passed to "%s()" must be an iterable, "%s" given.',
__METHOD__,
\is_object($value) ? 'instance of "'.$value::class.'"' : '"'.\gettype($value).'"'
\gettype($value)
));
}
}
4 changes: 2 additions & 2 deletions tests/Filter/Model/FilterDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function testTypeMustBeNumericOrNull(mixed $type): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(sprintf(
'The "type" parameter MUST be of type "integer" or "null", %s given.',
\is_object($type) ? 'instance of "'.$type::class.'"' : '"'.\gettype($type).'"'
'The "type" parameter MUST be of type "integer" or "null", "%s" given.',
\gettype($type)
));

// @phpstan-ignore-next-line
Expand Down
3 changes: 1 addition & 2 deletions tests/Filter/Persister/SessionFilterPersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public function testSetValueToSession(): void
DatagridInterface::PER_PAGE => 25,
];
$this->session->expects(static::once())->method('set')
->with('admin.customer.filter.parameters', $filters)
->willReturn(null);
->with('admin.customer.filter.parameters', $filters);

$this->createPersister()->set('admin.customer', $filters);
}
Expand Down
16 changes: 11 additions & 5 deletions tests/Form/AdminLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ public function testRowSetId(): void
$view = $form->createView();
$html = $this->renderRow($view);

self::assertMatchesXpath($html, '//div[@class="form-group"][@id="sonata-ba-field-container-name"]');
static::assertStringContainsString(
'<div id="sonata-ba-field-container-name" class="form-group">',
$html
);
}

public function testRowWithErrors(): void
Expand All @@ -158,7 +161,10 @@ public function testRowWithErrors(): void
$view = $form->createView();
$html = $this->renderRow($view);

self::assertMatchesXpath($html, '/div[@class="form-group has-error"][@id="sonata-ba-field-container-name"]');
static::assertStringContainsString(
'<div id="sonata-ba-field-container-name" class="form-group has-error">',
$html
);
}

public function testErrors(): void
Expand Down Expand Up @@ -208,9 +214,9 @@ public function testRowAttr(): void
$view = $form->createView();
$html = $this->renderRow($view);

self::assertMatchesXpath(
$html,
'//div[@class="foo form-group"][@data-value="bar"][@id="sonata-ba-field-container-name"]'
static::assertStringContainsString(
'<div class="foo form-group" data-value="bar" id="sonata-ba-field-container-name">',
$html
);
}

Expand Down
3 changes: 1 addition & 2 deletions tests/Form/Type/Filter/DateTimeRangeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType;
use Sonata\AdminBundle\Form\Type\Operator\DateRangeOperatorType;
use Sonata\Form\Type\DateTimeRangeType as FormDateTimeRangeType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
Expand Down Expand Up @@ -52,7 +51,7 @@ public function testGetDefaultOptions(): void
$expected = [
'operator_type' => DateRangeOperatorType::class,
'field_type' => FormDateTimeRangeType::class,
'field_options' => ['field_options' => ['date_format' => DateTimeType::HTML5_FORMAT]],
'field_options' => ['field_options' => []],
];
static::assertSame($expected, $options);
}
Expand Down
16 changes: 12 additions & 4 deletions tests/Form/Widget/FormChoiceWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\HttpKernel\Kernel;

final class FormChoiceWidgetTest extends BaseWidgetTest
{
Expand All @@ -40,10 +41,17 @@ public function testLabelRendering(): void

$html = $this->renderWidget($choice->createView());

static::assertStringContainsString(
'<li><div class="checkbox"><label><input type="checkbox" id="choice_0" name="choice[]" value="0" /><span class="control-label__text">[trans]some[/trans]</span></label></div></li>',
$this->cleanHtmlWhitespace($html)
);
if (0 !== preg_match("/7\..\../", Kernel::VERSION)) {
static::assertStringContainsString(
'<li><div class="checkbox"><label><input type="checkbox" id="choice_0" name="choice[]" value="0"><span class="control-label__text">[trans]some[/trans]</span></label></div></li>',
$this->cleanHtmlWhitespace($html)
);
} else {
static::assertStringContainsString(
'<li><div class="checkbox"><label><input type="checkbox" id="choice_0" name="choice[]" value="0" /><span class="control-label__text">[trans]some[/trans]</span></label></div></li>',
$this->cleanHtmlWhitespace($html)
);
}
}

public function testDefaultValueRendering(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/TraversableToCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public function provideFailedTransformCases(): iterable
yield ['"integer"', 0];
yield ['"integer"', 1];
yield ['"string"', 'a'];
yield ['instance of "stdClass"', new \stdClass()];
yield ['"object"', new \stdClass()];
}
}

0 comments on commit 2a219a0

Please sign in to comment.