mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Behat][ProductImage][TaxonImage] Fixes after PR review
This commit is contained in:
parent
0b9536960d
commit
87244101c1
19 changed files with 75 additions and 132 deletions
|
|
@ -14,7 +14,7 @@ Feature: Product image validation
|
|||
And I attach the "lamborghini.jpg" image without a code
|
||||
And I try to save my changes
|
||||
Then I should be notified that an image code is required
|
||||
And this product should not have images
|
||||
And this product should not have any images
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Trying to add a new image without specifying its code to a configurable product
|
||||
|
|
@ -23,4 +23,4 @@ Feature: Product image validation
|
|||
And I attach the "lamborghini.jpg" image without a code
|
||||
And I try to save my changes
|
||||
Then I should be notified that an image code is required
|
||||
And this product should not have images
|
||||
And this product should not have any images
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Feature: Removing images of an existing product
|
|||
And I remove an image with a code "thumbnail"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And this product should not have images
|
||||
And this product should not have any images
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Removing a single image of a configurable product
|
||||
|
|
@ -26,7 +26,7 @@ Feature: Removing images of an existing product
|
|||
And I remove an image with a code "thumbnail"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And this product should not have images
|
||||
And this product should not have any images
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Removing all images of a simple product
|
||||
|
|
@ -38,7 +38,7 @@ Feature: Removing images of an existing product
|
|||
And I remove also an image with a code "main"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And this product should not have images
|
||||
And this product should not have any images
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Removing all images of a configurable product
|
||||
|
|
@ -50,7 +50,7 @@ Feature: Removing images of an existing product
|
|||
And I remove also an image with a code "main"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And this product should not have images
|
||||
And this product should not have any images
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Removing only one image of a simple product
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Feature: Removing images of an existing taxon
|
|||
When I remove an image with a code "banner"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And this taxon should not have images
|
||||
And this taxon should not have any images
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Removing all images of a taxon
|
||||
|
|
@ -27,7 +27,7 @@ Feature: Removing images of an existing taxon
|
|||
When I remove also an image with a code "thumbnail"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And this taxon should not have images
|
||||
And this taxon should not have any images
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Removing only one image of a taxon
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ Feature: Taxon image validation
|
|||
And I attach the "t-shirts.jpg" image without a code
|
||||
And I try to save my changes
|
||||
Then I should be notified that an image code is required
|
||||
And this taxon should not have images
|
||||
And this taxon should not have any images
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ final class ManagingProductsContext implements Context
|
|||
$this->updateConfigurableProductPage,
|
||||
], $this->sharedStorage->has('product') ? $this->sharedStorage->get('product') : null);
|
||||
|
||||
$currentPage->attachImageWithCode($code, $path);
|
||||
$currentPage->attachImage($path, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -658,7 +658,7 @@ final class ManagingProductsContext implements Context
|
|||
$this->updateConfigurableProductPage,
|
||||
], $this->sharedStorage->get('product'));
|
||||
|
||||
$currentPage->attachImageWithoutCode($path);
|
||||
$currentPage->attachImage($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -741,7 +741,7 @@ final class ManagingProductsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then /^(this product) should not have images$/
|
||||
* @Then /^(this product) should not have any images$/
|
||||
*/
|
||||
public function thisProductShouldNotHaveImages(ProductInterface $product)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ final class ManagingTaxonsContext implements Context
|
|||
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
|
||||
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
||||
|
||||
$currentPage->attachImageWithCode($code, $path);
|
||||
$currentPage->attachImage($path, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -329,7 +329,7 @@ final class ManagingTaxonsContext implements Context
|
|||
*/
|
||||
public function iAttachImageWithoutACode($path)
|
||||
{
|
||||
$this->updatePage->attachImageWithoutCode($path);
|
||||
$this->updatePage->attachImage($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -371,7 +371,7 @@ final class ManagingTaxonsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then /^(this taxon) should not have images$/
|
||||
* @Then /^(this taxon) should not have any images$/
|
||||
*/
|
||||
public function thisTaxonShouldNotHaveImages(TaxonInterface $taxon)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class CreateConfigurableProductPage extends BaseCreatePage implements CreateConf
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithCode($code, $path)
|
||||
public function attachImage($path, $code = null)
|
||||
{
|
||||
$this->clickTabIfItsNotActive('media');
|
||||
|
||||
|
|
@ -56,7 +56,10 @@ class CreateConfigurableProductPage extends BaseCreatePage implements CreateConf
|
|||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
$imageForm->fillField('Code', $code);
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ interface CreateConfigurableProductPageInterface extends BaseCreatePageInterface
|
|||
public function nameItIn($name, $localeCode);
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string $path
|
||||
* @param string $code
|
||||
*/
|
||||
public function attachImageWithCode($code, $path);
|
||||
public function attachImage($path, $code = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class CreateSimpleProductPage extends BaseCreatePage implements CreateSimpleProd
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithCode($code, $path)
|
||||
public function attachImage($path, $code = null)
|
||||
{
|
||||
$this->clickTabIfItsNotActive('media');
|
||||
|
||||
|
|
@ -98,7 +98,10 @@ class CreateSimpleProductPage extends BaseCreatePage implements CreateSimpleProd
|
|||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
$imageForm->fillField('Code', $code);
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ interface CreateSimpleProductPageInterface extends BaseCreatePageInterface
|
|||
public function removeAttribute($attribute);
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string $path
|
||||
* @param string $code
|
||||
*/
|
||||
public function attachImageWithCode($code, $path);
|
||||
public function attachImage($path, $code = null);
|
||||
|
||||
public function enableSlugModification();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,17 +103,20 @@ class UpdateConfigurableProductPage extends BaseUpdatePage implements UpdateConf
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithCode($code, $path)
|
||||
public function attachImage($path, $code = null)
|
||||
{
|
||||
$this->attachImage($path, $code);
|
||||
}
|
||||
$this->clickTabIfItsNotActive('media');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithoutCode($path)
|
||||
{
|
||||
$this->attachImage($path);
|
||||
$filesPath = $this->getParameter('files_path');
|
||||
|
||||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -271,24 +274,4 @@ class UpdateConfigurableProductPage extends BaseUpdatePage implements UpdateConf
|
|||
|
||||
return reset($imageElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string|null $path
|
||||
*/
|
||||
private function attachImage($path, $code = null)
|
||||
{
|
||||
$this->clickTabIfItsNotActive('media');
|
||||
|
||||
$filesPath = $this->getParameter('files_path');
|
||||
|
||||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,15 +61,10 @@ interface UpdateConfigurableProductPageInterface extends UpdatePageInterface
|
|||
public function isImageWithCodeDisplayed($code);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $code
|
||||
* @param string $path
|
||||
*/
|
||||
public function attachImageWithCode($code, $path);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function attachImageWithoutCode($path);
|
||||
public function attachImage($path, $code = null);
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
|
|
|
|||
|
|
@ -136,17 +136,20 @@ class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProd
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithCode($code, $path)
|
||||
public function attachImage($path, $code = null)
|
||||
{
|
||||
$this->attachImage($path, $code);
|
||||
}
|
||||
$this->clickTabIfItsNotActive('media');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithoutCode($path)
|
||||
{
|
||||
$this->attachImage($path);
|
||||
$filesPath = $this->getParameter('files_path');
|
||||
|
||||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -331,24 +334,4 @@ class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProd
|
|||
return $value !== $slugElement->getValue();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string|null $path
|
||||
*/
|
||||
private function attachImage($path, $code = null)
|
||||
{
|
||||
$this->clickTabIfItsNotActive('media');
|
||||
|
||||
$filesPath = $this->getParameter('files_path');
|
||||
|
||||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,15 +84,10 @@ interface UpdateSimpleProductPageInterface extends BaseUpdatePageInterface
|
|||
public function isImageWithCodeDisplayed($code);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $code
|
||||
* @param string $path
|
||||
*/
|
||||
public function attachImageWithCode($code, $path);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function attachImageWithoutCode($path);
|
||||
public function attachImage($path, $code = null);
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithCode($code, $path)
|
||||
public function attachImage($path, $code = null)
|
||||
{
|
||||
$filesPath = $this->getParameter('files_path');
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ interface CreatePageInterface extends BaseCreatePageInterface
|
|||
public function specifyPermalink($permalink, $languageCode);
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string $path
|
||||
* @param string $code
|
||||
*/
|
||||
public function attachImageWithCode($code, $path);
|
||||
public function attachImage($path, $code = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,17 +60,18 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithCode($code, $path)
|
||||
public function attachImage($path, $code = null)
|
||||
{
|
||||
$this->attachImage($path, $code);
|
||||
}
|
||||
$filesPath = $this->getParameter('files_path');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachImageWithoutCode($path)
|
||||
{
|
||||
$this->attachImage($path);
|
||||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -237,22 +238,4 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
|
||||
return $inputCode->getParent()->getParent()->getParent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string|null $path
|
||||
*/
|
||||
private function attachImage($path, $code = null)
|
||||
{
|
||||
$filesPath = $this->getParameter('files_path');
|
||||
|
||||
$this->getDocument()->clickLink('Add');
|
||||
|
||||
$imageForm = $this->getLastImageElement();
|
||||
if (null !== $code) {
|
||||
$imageForm->fillField('Code', $code);
|
||||
}
|
||||
|
||||
$imageForm->find('css', 'input[type="file"]')->attachFile($filesPath.$path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,15 +54,10 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
|
|||
public function isImageCodeDisabled();
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $code
|
||||
* @param string $path
|
||||
*/
|
||||
public function attachImageWithCode($code, $path);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function attachImageWithoutCode($path);
|
||||
public function attachImage($path, $code = null);
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
<class name="Sylius\Component\Core\Model\Taxon">
|
||||
<property name="images">
|
||||
<constraint name="Valid" />
|
||||
<constraint name="Sylius\Bundle\CoreBundle\Validator\Constraints\ImageUniqueCode">
|
||||
<option name="message">sylius.taxon_image.code.unique</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
</constraint-mapping>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue