Merge branch '1.7' into 1.8

* 1.7:
  Added: Behat test for taxon creation with parent specified
  Fixed: Parent taxon selection on taxon creation (fixes #11777)
This commit is contained in:
Łukasz Chruściel 2020-09-09 13:51:45 +02:00
commit f4704f1b93
No known key found for this signature in database
GPG key ID: 428B9D810DB2ACDF
4 changed files with 28 additions and 15 deletions

View file

@ -0,0 +1,22 @@
@managing_taxons
Feature: Adding a new taxon with parent specified
In order to categorize my merchandise
As an Administrator
I want to add a new taxon with specific parent to the registry
Background:
Given the store is available in "English (United States)"
And the store has "Category" taxonomy
And I am logged in as an administrator
@ui @javascript
Scenario: Adding a new taxon with parent
Given I want to create a new taxon
And I set its parent taxon to "category"
And I specify its code as "guns"
And I name it "Guns" in "English (United States)"
And I set its slug to "guns" in "English (United States)"
And I add it
Then I should be notified that it has been successfully created
And the "Guns" taxon should appear in the registry
And this taxon should belongs to "Category"

View file

@ -156,6 +156,7 @@ final class ManagingTaxonsContext implements Context
}
/**
* @Given /^I set its (parent taxon to "[^"]+")$/
* @Given /^I change its (parent taxon to "[^"]+")$/
*/
public function iChangeItsParentTaxonTo(TaxonInterface $taxon)

View file

@ -4,11 +4,7 @@
{{ form_errors(form) }}
<div class="two fields">
{{ form_row(form.code) }}
{% if taxon.id != null %}
{{ form_row(form.parent) }}
{% else %}
{{ form_widget(form.parent, {'attr': {'style': 'display: none;'}}) }}
{% endif %}
{{ form_row(form.parent) }}
</div>
<div class="fields">
{{ form_row(form.enabled) }}

View file

@ -35,16 +35,10 @@ final class TaxonType extends AbstractResourceType
'label' => 'sylius.form.taxon.enabled',
])
->addEventSubscriber(new AddCodeFormSubscriber())
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
if (null === $event->getData()) {
return;
}
$event->getForm()->add('parent', TaxonAutocompleteChoiceType::class, [
'label' => 'sylius.form.taxon.parent',
'required' => false,
]);
})
->add('parent', TaxonAutocompleteChoiceType::class, [
'label' => 'sylius.form.taxon.parent',
'required' => false,
])
;
}