Skip to content

Commit

Permalink
Merge pull request magento#4931 from magento-arcticfoxes/MC-21994
Browse files Browse the repository at this point in the history
[arcticfoxes] MC-21994: Magento\Catalog\Controller\Adminhtml\Product\Gallery\UploadTest::testUploadActionWithErrors
  • Loading branch information
joanhe authored Oct 30, 2019
2 parents cc67aa0 + 69ee87c commit b6e9491
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ public function execute()
['fileId' => 'image']
);
$uploader->setAllowedExtensions($this->getAllowedExtensions());

if (!$uploader->checkMimeType($this->getAllowedMimeTypes())) {
throw new LocalizedException(__('Disallowed File Type.'));
}

$imageAdapter = $this->adapterFactory->create();
$uploader->addValidateCallback('catalog_product_image', $imageAdapter, 'validateUploadFile');
$uploader->setAllowRenameFiles(true);
Expand Down Expand Up @@ -133,14 +128,4 @@ private function getAllowedExtensions()
{
return array_keys($this->allowedMimeTypes);
}

/**
* Get the set of allowed mime types.
*
* @return array
*/
private function getAllowedMimeTypes()
{
return array_values($this->allowedMimeTypes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@
<click selector="{{AdminProductFormSection.advancedInventoryLink}}" stepKey="clickOnAdvancedInventoryLink"/>
<waitForPageLoad stepKey="waitForAdvancedInventoryPageToLoad"/>
</actionGroup>

<!-- ActionGroup click on Advanced Inventory Button in product form;
You must already be on the product form page -->
<actionGroup name="AdminClickOnAdvancedInventoryButtonActionGroup">
<annotations>
<description>Clicks on the 'Advanced Inventory' link on the Admin Product creation/edit page.</description>
</annotations>

<click selector="{{AdminProductFormSection.advancedInventoryButton}}" stepKey="clickOnAdvancedInventoryLink"/>
<waitForPageLoad stepKey="waitForAdvancedInventoryPageToLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']" timeout="30"/>
<element name="unselectCategories" type="button" selector="//span[@class='admin__action-multiselect-crumb']/span[contains(.,'{{category}}')]/../button[@data-action='remove-selected-item']" parameterized="true" timeout="30"/>
<element name="productQuantity" type="input" selector=".admin__field[data-index=qty] input"/>
<element name="advancedInventoryLink" type="button" selector="//button[contains(@data-index, 'advanced_inventory_button')]" timeout="30"/>
<element name="advancedInventoryLink" type="button" selector="button[data-index='advanced_inventory_button'].action-additional" timeout="30"/>
<element name="productStockStatus" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]']" timeout="30"/>
<element name="productStockStatusDisabled" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]'][disabled=true]"/>
<element name="stockStatus" type="select" selector="[data-index='product-details'] select[name='product[quantity_and_stock_status][is_in_stock]']"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminProductFormSection">
<element name="advancedInventoryLink" type="button" selector="button[data-index='advanced_inventory_button']" timeout="30"/>
<element name="advancedInventoryLink" type="button" selector="button[data-index='advanced_inventory_button'].action-additional" timeout="30"/>
<element name="advancedInventoryButton" type="button" selector="button[data-index='advanced_inventory_button'].action-basic" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<element name="updateChangesBtn" type="button" selector=".order-sidebar .actions .action-default.scalable" timeout="30"/>
<element name="productName" type="text" selector="#order-items_grid span[id*=order_item]"/>
<element name="productPrice" type="text" selector=".even td[class=col-price] span[class=price]"/>
<element name="productQty" type="input" selector="td[class=col-qty] input"/>
<element name="productQty" type="input" selector="td[class=col-qty] .input-text.item-qty.admin__control-text"/>
<element name="gridCell" type="text" selector="//div[contains(@id, 'order-items_grid')]//tbody[{{row}}]//td[count(//table[contains(@class, 'order-tables')]//th[contains(., '{{column}}')]/preceding-sibling::th) +1 ]" parameterized="true" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ public function uploadActionDataProvider(): array
*/
public function testUploadActionWithErrors(array $file, array $expectation): void
{
$this->markTestSkipped('MC-21994');

if (!empty($file['create_file'])) {
$this->createFileInSysTmpDir($file['name']);
} elseif (!empty($file['copy_file'])) {
Expand All @@ -165,8 +163,8 @@ public function testUploadActionWithErrors(array $file, array $expectation): voi
$this->getRequest()->setMethod($this->httpMethod);
$this->dispatch($this->uri);
$jsonBody = $this->serializer->unserialize($this->getResponse()->getBody());
$this->assertEquals($jsonBody['error'], $expectation['message']);
$this->assertEquals($jsonBody['errorcode'], $expectation['errorcode']);
$this->assertEquals($expectation['message'], $jsonBody['error']);
$this->assertEquals($expectation['errorcode'], $jsonBody['errorcode']);

if (!empty($expectation['tmp_media_path'])) {
$this->assertFileNotExists(
Expand Down

0 comments on commit b6e9491

Please sign in to comment.