Skip to content

Tests for: magento/magento2#25600, magento/magento2#25528, magento/magento2#25613, magento/magento2#25606. #25704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontForthLevelCategoryTest">
<annotations>
<features value="Catalog"/>
<stories value="Category"/>
<title value="Storefront forth level category test"/>
<description value="When the submenu was created in the third stage follow, the submenu works"/>
<severity value="MAJOR"/>
<group value="Catalog"/>
</annotations>
<before>
<createData entity="SimpleSubCategory" stepKey="category1"/>
<createData entity="SubCategoryWithParent" stepKey="category2">
<requiredEntity createDataKey="category1"/>
</createData>
<createData entity="SubCategoryWithParent" stepKey="category3">
<requiredEntity createDataKey="category2"/>
</createData>
<createData entity="SubCategoryWithParent" stepKey="category4">
<requiredEntity createDataKey="category3"/>
</createData>
</before>
<after>
<deleteData createDataKey="category4" stepKey="deleteCategory4"/>
<deleteData createDataKey="category3" stepKey="deleteCategory3"/>
<deleteData createDataKey="category2" stepKey="deleteCategory2"/>
<deleteData createDataKey="category1" stepKey="deleteCategory1"/>
</after>
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnStorefrontPage"/>
<moveMouseOver
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category1.name$$)}}"
stepKey="hoverCategoryLevelOne"/>
<moveMouseOver
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category2.name$$)}}"
stepKey="hoverCategoryLevelTwo"/>
<moveMouseOver
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category3.name$$)}}"
stepKey="hoverCategoryLevelThree"/>
<moveMouseOver
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category4.name$$)}}"
stepKey="hoverCategoryLevelFour"/>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Test\Unit\Model\Product\Image;

use Magento\Catalog\Model\Product\Image;
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Config\View;
use Magento\Framework\View\ConfigInterface;
use Magento\Store\Model\ScopeInterface;

class ParamsBuilderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @var ConfigInterface
*/
private $viewConfig;

/**
* @var ParamsBuilder
*/
private $model;

protected function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
$this->viewConfig = $this->createMock(ConfigInterface::class);
$this->model = $objectManager->getObject(
ParamsBuilder::class,
[
'scopeConfig' => $this->scopeConfig,
'viewConfig' => $this->viewConfig,
]
);
}

/**
* Test watermark location.
*/
public function testWatermarkLocation()
{
$imageArguments = [
'type' => 'type',
'height' => 'image_height',
'width' => 'image_width',
'angle' => 'angle',
'background' => [1, 2, 3]
];
$scopeId = 1;
$quality = 100;
$file = 'file';
$width = 'width';
$height = 'height';
$size = "{$width}x{$height}";
$opacity = 'opacity';
$position = 'position';

$viewMock = $this->createMock(View::class);
$viewMock->expects($this->once())
->method('getVarValue')
->with('Magento_Catalog', 'product_image_white_borders')
->willReturn(true);

$this->viewConfig->expects($this->once())
->method('getViewConfig')
->with(['area' => Area::AREA_FRONTEND])
->willReturn($viewMock);

$this->scopeConfig->expects($this->exactly(5))->method('getValue')->withConsecutive(
[
Image::XML_PATH_JPEG_QUALITY
],
[
"design/watermark/{$imageArguments['type']}_image",
ScopeInterface::SCOPE_STORE,
$scopeId,
],
[
"design/watermark/{$imageArguments['type']}_size",
ScopeInterface::SCOPE_STORE],
[
"design/watermark/{$imageArguments['type']}_imageOpacity",
ScopeInterface::SCOPE_STORE,
$scopeId
],
[
"design/watermark/{$imageArguments['type']}_position",
ScopeInterface::SCOPE_STORE,
$scopeId
]
)->willReturnOnConsecutiveCalls(
$quality,
$file,
$size,
$opacity,
$position
);

$actual = $this->model->build($imageArguments, $scopeId);
$expected = [
'image_type' => $imageArguments['type'],
'background' => $imageArguments['background'],
'angle' => $imageArguments['angle'],
'quality' => $quality,
'keep_aspect_ratio' => true,
'keep_frame' => true,
'keep_transparency' => true,
'constrain_only' => true,
'watermark_file' => $file,
'watermark_image_opacity' => $opacity,
'watermark_position' => $position,
'watermark_width' => $width,
'watermark_height' => $height,
'image_height' => $imageArguments['height'],
'image_width' => $imageArguments['width'],
];

$this->assertEquals(
$expected,
$actual
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<element name="goToCheckout" type="button" selector="#top-cart-btn-checkout" timeout="30"/>
<element name="viewAndEditCart" type="button" selector=".action.viewcart" timeout="30"/>
<element name="miniCartItemsText" type="text" selector=".minicart-items"/>
<element name="editMiniCartItem" type="button" selector=".action.edit" timeout="30"/>
<element name="deleteMiniCartItem" type="button" selector=".action.delete" timeout="30"/>
<element name="deleteMiniCartItemByName" type="button" selector="//ol[@id='mini-cart']//div[contains(., '{{var}}')]//a[contains(@class, 'delete')]" parameterized="true"/>
<element name="miniCartSubtotalField" type="text" selector=".block-minicart .amount span.price"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="NoErrorForMiniCartItemEditTest">
<annotations>
<features value="ConfigurableProduct"/>
<title value="No error for minicart item edit test"/>
<description value="Already selected configurable option should be selected when configurable product is edited from minicart"/>
<severity value="MAJOR"/>
<group value="ConfigurableProduct"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
<createData entity="ApiCategory" stepKey="createCategory"/>
<!-- Create Configurable product -->
<actionGroup ref="createConfigurableProduct" stepKey="createProduct">
<argument name="product" value="_defaultProduct"/>
<argument name="category" value="$$createCategory$$"/>
</actionGroup>
</before>
<after>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<!-- Delete the first simple product -->
<actionGroup stepKey="deleteProduct1" ref="deleteProductBySku">
<argument name="sku" value="{{_defaultProduct.sku}}"/>
</actionGroup>
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}"
dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true"
stepKey="clickClearFilters"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>

<!-- Go To Created Product Page -->
<amOnPage stepKey="goToCreatedProductPage" url="{{_defaultProduct.urlKey}}.html"/>
<waitForPageLoad stepKey="waitForProductPageLoad2"/>

<!-- Add Product to Cart -->
<seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}"
stepKey="checkDropDownProductOption"/>
<selectOption userInput="{{colorProductAttribute1.name}}"
selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
stepKey="selectOption1"/>
<selectOption userInput="{{colorProductAttribute2.name}}"
selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
stepKey="selectOption2"/>
<click selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}"
stepKey="clickDropDownProductOption"/>
<selectOption userInput="{{colorProductAttribute1.name}}"
selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
stepKey="selectOptionForAddingToCart"/>
<click selector="{{StorefrontProductInfoMainSection.AddToCart}}" stepKey="clickAddToCart"/>
<waitForPageLoad stepKey="waitForMiniCart"/>

<!-- Edit Item in Cart -->
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart"/>
<click selector="{{StorefrontMinicartSection.editMiniCartItem}}" stepKey="clickEditCartItem"/>

<!-- Check if Product Configuration is still selected -->
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
userInput="{{colorProductAttribute1.name}}" stepKey="seeConfigurationSelected"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\App\Test\Unit;

use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\Request\ValidatorInterface;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Message\ManagerInterface as MessageManager;
use Psr\Log\LoggerInterface;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class FrontControllerTest extends \PHPUnit\Framework\TestCase
{
/**
Expand Down Expand Up @@ -34,6 +42,21 @@ class FrontControllerTest extends \PHPUnit\Framework\TestCase
*/
protected $response;

/**
* @var \PHPUnit\Framework\MockObject\MockObject|ValidatorInterface
*/
private $requestValidator;

/**
* @var \PHPUnit\Framework\MockObject\MockObject|\MessageManager
*/
private $messages;

/**
* @var \PHPUnit\Framework\MockObject\MockObject|\LoggerInterface
*/
private $logger;

protected function setUp()
{
$this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
Expand All @@ -44,7 +67,16 @@ protected function setUp()
$this->router = $this->createMock(\Magento\Framework\App\RouterInterface::class);
$this->routerList = $this->createMock(\Magento\Framework\App\RouterList::class);
$this->response = $this->createMock(\Magento\Framework\App\Response\Http::class);
$this->model = new \Magento\Framework\App\FrontController($this->routerList, $this->response);
$this->requestValidator = $this->createMock(ValidatorInterface::class);
$this->messages = $this->createMock(MessageManager::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->model = new \Magento\Framework\App\FrontController(
$this->routerList,
$this->response,
$this->requestValidator,
$this->messages,
$this->logger
);
}

/**
Expand All @@ -55,7 +87,8 @@ public function testDispatchThrowException()
{
$validCounter = 0;
$callbackValid = function () use (&$validCounter) {
return $validCounter++%10 ? false : true;
$validCounter++;
return $validCounter % 10 ? false : true;
};
$this->routerList->expects($this->any())->method('valid')->will($this->returnCallback($callbackValid));

Expand All @@ -73,6 +106,54 @@ public function testDispatchThrowException()
$this->model->dispatch($this->request);
}

/**
* Check adding validation failure message to debug log.
*/
public function testAddingValidationFailureMessageToDebugLog()
{
$exceptionMessage = 'exception_message';
$exception = new InvalidRequestException($exceptionMessage);

$this->routerList->expects($this->any())
->method('valid')
->will($this->returnValue(true));

$response = $this->createMock(\Magento\Framework\App\Response\Http::class);
$controllerInstance = $this->getMockBuilder(\Magento\Framework\App\Action\Action::class)
->disableOriginalConstructor()
->getMock();
$controllerInstance->expects($this->any())
->method('dispatch')
->with($this->request)
->will($this->returnValue($response));
$this->router->expects($this->at(0))
->method('match')
->with($this->request)
->will($this->returnValue(false));
$this->router->expects($this->at(1))
->method('match')
->with($this->request)
->will($this->returnValue($controllerInstance));

$this->routerList->expects($this->any())
->method('current')
->will($this->returnValue($this->router));

$this->request->expects($this->at(0))->method('isDispatched')->will($this->returnValue(false));
$this->request->expects($this->at(1))->method('setDispatched')->with(true);
$this->request->expects($this->at(2))->method('isDispatched')->will($this->returnValue(true));

$this->requestValidator->expects($this->once())
->method('validate')->with($this->request, $controllerInstance)->willThrowException($exception);
$this->logger->expects($this->once())->method('debug')->with(
'Request validation failed for action "'
. get_class($controllerInstance) . '"',
["exception" => $exception]
);

$this->assertEquals($exceptionMessage, $this->model->dispatch($this->request));
}

public function testDispatched()
{
$this->routerList->expects($this->any())
Expand Down