mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Ordering the keys correctly
This commit is contained in:
parent
ba889c63a1
commit
5323a596cc
4 changed files with 49 additions and 34 deletions
|
|
@ -68,6 +68,15 @@ final class CatalogPromotionGrid extends AbstractGrid implements CatalogPromotio
|
||||||
->setLabel('sylius.ui.code')
|
->setLabel('sylius.ui.code')
|
||||||
->setSortable(true),
|
->setSortable(true),
|
||||||
)
|
)
|
||||||
|
->addField(
|
||||||
|
TwigField::create('channels', '@SyliusAdmin/shared/grid/field/channels.html.twig')
|
||||||
|
->setLabel('sylius.ui.channels')
|
||||||
|
->withOptions([
|
||||||
|
'vars' => [
|
||||||
|
'th_class' => 'w-1 text-center',
|
||||||
|
],
|
||||||
|
]),
|
||||||
|
)
|
||||||
->addField(
|
->addField(
|
||||||
TwigField::create('startDate', '@SyliusAdmin/catalog_promotion/grid/field/date.html.twig')
|
TwigField::create('startDate', '@SyliusAdmin/catalog_promotion/grid/field/date.html.twig')
|
||||||
->setLabel('sylius.ui.start_date')
|
->setLabel('sylius.ui.start_date')
|
||||||
|
|
@ -88,15 +97,6 @@ final class CatalogPromotionGrid extends AbstractGrid implements CatalogPromotio
|
||||||
],
|
],
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
->addField(
|
|
||||||
TwigField::create('channels', '@SyliusAdmin/shared/grid/field/channels.html.twig')
|
|
||||||
->setLabel('sylius.ui.channels')
|
|
||||||
->withOptions([
|
|
||||||
'vars' => [
|
|
||||||
'th_class' => 'w-1 text-center',
|
|
||||||
],
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
->addField(
|
->addField(
|
||||||
TwigField::create('state', '@SyliusAdmin/catalog_promotion/grid/field/state.html.twig')
|
TwigField::create('state', '@SyliusAdmin/catalog_promotion/grid/field/state.html.twig')
|
||||||
->setLabel('sylius.ui.state')
|
->setLabel('sylius.ui.state')
|
||||||
|
|
|
||||||
|
|
@ -96,19 +96,6 @@ final class ProductGrid extends AbstractGrid implements ProductGridInterface
|
||||||
EntityFilter::create('channel', $this->channelClass, fields: ['channels.id'])
|
EntityFilter::create('channel', $this->channelClass, fields: ['channels.id'])
|
||||||
->setLabel('sylius.ui.channel'),
|
->setLabel('sylius.ui.channel'),
|
||||||
)
|
)
|
||||||
->addFilter(
|
|
||||||
Filter::create('main_taxon', 'ux_translatable_autocomplete')
|
|
||||||
->setLabel('sylius.ui.main_taxon')
|
|
||||||
->setFormOptions([
|
|
||||||
'multiple' => false,
|
|
||||||
'extra_options' => [
|
|
||||||
'class' => $this->taxonClass,
|
|
||||||
'translation_fields' => ['name'],
|
|
||||||
'choice_label' => 'fullname',
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->addOption('fields', ['mainTaxon.id']),
|
|
||||||
)
|
|
||||||
->addFilter(
|
->addFilter(
|
||||||
Filter::create('taxon', 'ux_translatable_autocomplete')
|
Filter::create('taxon', 'ux_translatable_autocomplete')
|
||||||
->setLabel('sylius.ui.taxon')
|
->setLabel('sylius.ui.taxon')
|
||||||
|
|
@ -122,6 +109,19 @@ final class ProductGrid extends AbstractGrid implements ProductGridInterface
|
||||||
])
|
])
|
||||||
->addOption('fields', ['productTaxons.taxon.id']),
|
->addOption('fields', ['productTaxons.taxon.id']),
|
||||||
)
|
)
|
||||||
|
->addFilter(
|
||||||
|
Filter::create('main_taxon', 'ux_translatable_autocomplete')
|
||||||
|
->setLabel('sylius.ui.main_taxon')
|
||||||
|
->setFormOptions([
|
||||||
|
'multiple' => false,
|
||||||
|
'extra_options' => [
|
||||||
|
'class' => $this->taxonClass,
|
||||||
|
'translation_fields' => ['name'],
|
||||||
|
'choice_label' => 'fullname',
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->addOption('fields', ['mainTaxon.id']),
|
||||||
|
)
|
||||||
|
|
||||||
// -- Actions
|
// -- Actions
|
||||||
->addActionGroup(
|
->addActionGroup(
|
||||||
|
|
|
||||||
|
|
@ -125,11 +125,6 @@ final class PromotionGrid extends AbstractGrid implements PromotionGridInterface
|
||||||
Action::create('archive', 'archive'),
|
Action::create('archive', 'archive'),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
->addActionGroup(
|
|
||||||
BulkActionGroup::create(
|
|
||||||
DeleteAction::create(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
->addActionGroup(
|
->addActionGroup(
|
||||||
ActionGroup::create(
|
ActionGroup::create(
|
||||||
'subitem',
|
'subitem',
|
||||||
|
|
@ -163,6 +158,11 @@ final class PromotionGrid extends AbstractGrid implements PromotionGridInterface
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
->addActionGroup(
|
||||||
|
BulkActionGroup::create(
|
||||||
|
DeleteAction::create(),
|
||||||
|
),
|
||||||
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,13 +132,18 @@ final class OverridenGridsTest extends KernelTestCase
|
||||||
{
|
{
|
||||||
self::assertSame($yamlGrid->getCode(), $serviceGrid->getCode());
|
self::assertSame($yamlGrid->getCode(), $serviceGrid->getCode());
|
||||||
self::assertSame($yamlGrid->getDriver(), $serviceGrid->getDriver());
|
self::assertSame($yamlGrid->getDriver(), $serviceGrid->getDriver());
|
||||||
self::assertSameIgnoreOrder($yamlGrid->getDriverConfiguration(), $serviceGrid->getDriverConfiguration());
|
self::assertSameWithIgnoredOrder($yamlGrid->getDriverConfiguration(), $serviceGrid->getDriverConfiguration());
|
||||||
self::assertSame($yamlGrid->getProvider(), $serviceGrid->getProvider());
|
self::assertSame($yamlGrid->getProvider(), $serviceGrid->getProvider());
|
||||||
self::assertSame($yamlGrid->getSorting(), $serviceGrid->getSorting());
|
self::assertSame($yamlGrid->getSorting(), $serviceGrid->getSorting());
|
||||||
self::assertSame($yamlGrid->getLimits(), $serviceGrid->getLimits());
|
self::assertSame($yamlGrid->getLimits(), $serviceGrid->getLimits());
|
||||||
self::assertSame($yamlGrid->getSorting(), $serviceGrid->getSorting());
|
self::assertSame($yamlGrid->getSorting(), $serviceGrid->getSorting());
|
||||||
|
|
||||||
$serviceFields = $serviceGrid->getFields();
|
$serviceFields = $serviceGrid->getFields();
|
||||||
|
$this->assertSame(
|
||||||
|
array_keys($serviceGrid->getFields()),
|
||||||
|
array_keys($yamlGrid->getFields()),
|
||||||
|
'Field keys in grid do not match',
|
||||||
|
);
|
||||||
foreach ($yamlGrid->getFields() as $fieldName => $yamlField) {
|
foreach ($yamlGrid->getFields() as $fieldName => $yamlField) {
|
||||||
$this->assertArrayHasKey($fieldName, $serviceFields);
|
$this->assertArrayHasKey($fieldName, $serviceFields);
|
||||||
$this->assertEquals($yamlField, $serviceFields[$fieldName]);
|
$this->assertEquals($yamlField, $serviceFields[$fieldName]);
|
||||||
|
|
@ -151,11 +156,16 @@ final class OverridenGridsTest extends KernelTestCase
|
||||||
$this->assertSame($yamlField->isEnabled(), $serviceField->isEnabled(), 'Enabled state of field '.$fieldName.' does not match');
|
$this->assertSame($yamlField->isEnabled(), $serviceField->isEnabled(), 'Enabled state of field '.$fieldName.' does not match');
|
||||||
$this->assertSame($yamlField->isSortable(), $serviceField->isSortable(), 'Sortable state of field '.$fieldName.' does not match');
|
$this->assertSame($yamlField->isSortable(), $serviceField->isSortable(), 'Sortable state of field '.$fieldName.' does not match');
|
||||||
$this->assertSame($yamlField->getSortable(), $serviceField->getSortable(), 'Sortable path of field '.$fieldName.' does not match');
|
$this->assertSame($yamlField->getSortable(), $serviceField->getSortable(), 'Sortable path of field '.$fieldName.' does not match');
|
||||||
$this->assertSameIgnoreOrder($yamlField->getOptions(), $serviceField->getOptions(), 'Options of field '.$fieldName.' do not match');
|
$this->assertSameWithIgnoredOrder($yamlField->getOptions(), $serviceField->getOptions(), 'Options of field '.$fieldName.' do not match');
|
||||||
$this->assertSame($yamlField->getPosition(), $serviceField->getPosition(), 'Position of field '.$fieldName.' does not match');
|
$this->assertSame($yamlField->getPosition(), $serviceField->getPosition(), 'Position of field '.$fieldName.' does not match');
|
||||||
}
|
}
|
||||||
|
|
||||||
$serviceFilters = $serviceGrid->getFilters();
|
$serviceFilters = $serviceGrid->getFilters();
|
||||||
|
$this->assertSame(
|
||||||
|
array_keys($serviceGrid->getFilters()),
|
||||||
|
array_keys($yamlGrid->getFilters()),
|
||||||
|
'Filter keys in grid do not match',
|
||||||
|
);
|
||||||
foreach ($yamlGrid->getFilters() as $filterName => $yamlFilter) {
|
foreach ($yamlGrid->getFilters() as $filterName => $yamlFilter) {
|
||||||
$this->assertArrayHasKey($filterName, $serviceFilters);
|
$this->assertArrayHasKey($filterName, $serviceFilters);
|
||||||
|
|
||||||
|
|
@ -165,20 +175,25 @@ final class OverridenGridsTest extends KernelTestCase
|
||||||
$this->assertSame($yamlFilter->getType(), $serviceFilter->getType(), 'Type of filter '.$filterName. ' does not match');
|
$this->assertSame($yamlFilter->getType(), $serviceFilter->getType(), 'Type of filter '.$filterName. ' does not match');
|
||||||
$this->assertSame($yamlFilter->getLabel(), $serviceFilter->getLabel(), 'Label of filter '.$filterName. ' does not match');
|
$this->assertSame($yamlFilter->getLabel(), $serviceFilter->getLabel(), 'Label of filter '.$filterName. ' does not match');
|
||||||
$this->assertSame($yamlFilter->getTemplate(), $serviceFilter->getTemplate(), 'Template of filter '.$filterName. ' does not match');
|
$this->assertSame($yamlFilter->getTemplate(), $serviceFilter->getTemplate(), 'Template of filter '.$filterName. ' does not match');
|
||||||
$this->assertSameIgnoreOrder($yamlFilter->getOptions(), $serviceFilter->getOptions(), 'Options of filter '.$filterName. ' does not match');
|
$this->assertSameWithIgnoredOrder($yamlFilter->getOptions(), $serviceFilter->getOptions(), 'Options of filter '.$filterName. ' does not match');
|
||||||
$this->assertSameIgnoreOrder($yamlFilter->getFormOptions(), $serviceFilter->getFormOptions(), 'Form Options of filter '.$filterName. ' does not match');
|
$this->assertSameWithIgnoredOrder($yamlFilter->getFormOptions(), $serviceFilter->getFormOptions(), 'Form Options of filter '.$filterName. ' does not match');
|
||||||
$this->assertSame($yamlFilter->getCriteria(), $serviceFilter->getCriteria(), 'Criteria of filter '.$filterName. ' does not match');
|
$this->assertSame($yamlFilter->getCriteria(), $serviceFilter->getCriteria(), 'Criteria of filter '.$filterName. ' does not match');
|
||||||
$this->assertSame($yamlFilter->getPosition(), $serviceFilter->getPosition(), 'Position of filter '.$filterName. ' does not match');
|
$this->assertSame($yamlFilter->getPosition(), $serviceFilter->getPosition(), 'Position of filter '.$filterName. ' does not match');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert actions are the same
|
// Assert actions are the same
|
||||||
|
$this->assertSame(
|
||||||
|
array_keys($serviceGrid->getActionGroups()),
|
||||||
|
array_keys($yamlGrid->getActionGroups()),
|
||||||
|
'Action keys in action groups do not match',
|
||||||
|
);
|
||||||
$serviceActions = $serviceGrid->getActionGroups();
|
$serviceActions = $serviceGrid->getActionGroups();
|
||||||
foreach ($yamlGrid->getActionGroups() as $actionGroupName => $yamlActionGroup) {
|
foreach ($yamlGrid->getActionGroups() as $actionGroupName => $yamlActionGroup) {
|
||||||
$this->assertArrayHasKey($actionGroupName, $serviceActions);
|
$this->assertArrayHasKey($actionGroupName, $serviceActions);
|
||||||
$this->assertEquals($yamlActionGroup, $serviceActions[$actionGroupName]);
|
$this->assertEquals($yamlActionGroup, $serviceActions[$actionGroupName]);
|
||||||
$serviceActionGroup = $serviceActions[$actionGroupName];
|
$serviceActionGroup = $serviceActions[$actionGroupName];
|
||||||
|
|
||||||
$this->assertSameIgnoreOrder(
|
$this->assertSame(
|
||||||
array_keys($serviceActionGroup->getActions()),
|
array_keys($serviceActionGroup->getActions()),
|
||||||
array_keys($yamlActionGroup->getActions()),
|
array_keys($yamlActionGroup->getActions()),
|
||||||
'Action keys in action group '.$actionGroupName.' do not match',
|
'Action keys in action group '.$actionGroupName.' do not match',
|
||||||
|
|
@ -192,13 +207,13 @@ final class OverridenGridsTest extends KernelTestCase
|
||||||
$this->assertSame($expectedAction->isEnabled(), $actualAction->isEnabled(), 'Enabled state of action '.$actionGroupName.' does not match');
|
$this->assertSame($expectedAction->isEnabled(), $actualAction->isEnabled(), 'Enabled state of action '.$actionGroupName.' does not match');
|
||||||
$this->assertSame($expectedAction->getTemplate(), $actualAction->getTemplate(), 'Template of action '.$actionGroupName.' does not match');
|
$this->assertSame($expectedAction->getTemplate(), $actualAction->getTemplate(), 'Template of action '.$actionGroupName.' does not match');
|
||||||
$this->assertSame($expectedAction->getIcon(), $actualAction->getIcon(), 'Icon of action '.$actionGroupName.' does not match');
|
$this->assertSame($expectedAction->getIcon(), $actualAction->getIcon(), 'Icon of action '.$actionGroupName.' does not match');
|
||||||
$this->assertSameIgnoreOrder($expectedAction->getOptions(), $actualAction->getOptions(), 'Options of action '.$actionGroupName.' do not match');
|
$this->assertSameWithIgnoredOrder($expectedAction->getOptions(), $actualAction->getOptions(), 'Options of action '.$actionGroupName.' do not match');
|
||||||
$this->assertSame($expectedAction->getPosition(), $actualAction->getPosition(), 'Position of action '.$actionGroupName.' does not match');
|
$this->assertSame($expectedAction->getPosition(), $actualAction->getPosition(), 'Position of action '.$actionGroupName.' does not match');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertSameIgnoreOrder(array $expected, array $actual): void
|
private function assertSameWithIgnoredOrder(array $expected, array $actual): void
|
||||||
{
|
{
|
||||||
ksort($expected);
|
ksort($expected);
|
||||||
ksort($actual);
|
ksort($actual);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue