Skip to content

Commit 768707f

Browse files
ENGCOM-6370: Tests for: #25600, #25528, #25613, #25606. #25704
2 parents 24bff33 + feaeec5 commit 768707f

File tree

5 files changed

+339
-2
lines changed

5 files changed

+339
-2
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontForthLevelCategoryTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Category"/>
15+
<title value="Storefront forth level category test"/>
16+
<description value="When the submenu was created in the third stage follow, the submenu works"/>
17+
<severity value="MAJOR"/>
18+
<group value="Catalog"/>
19+
</annotations>
20+
<before>
21+
<createData entity="SimpleSubCategory" stepKey="category1"/>
22+
<createData entity="SubCategoryWithParent" stepKey="category2">
23+
<requiredEntity createDataKey="category1"/>
24+
</createData>
25+
<createData entity="SubCategoryWithParent" stepKey="category3">
26+
<requiredEntity createDataKey="category2"/>
27+
</createData>
28+
<createData entity="SubCategoryWithParent" stepKey="category4">
29+
<requiredEntity createDataKey="category3"/>
30+
</createData>
31+
</before>
32+
<after>
33+
<deleteData createDataKey="category4" stepKey="deleteCategory4"/>
34+
<deleteData createDataKey="category3" stepKey="deleteCategory3"/>
35+
<deleteData createDataKey="category2" stepKey="deleteCategory2"/>
36+
<deleteData createDataKey="category1" stepKey="deleteCategory1"/>
37+
</after>
38+
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnStorefrontPage"/>
39+
<moveMouseOver
40+
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category1.name$$)}}"
41+
stepKey="hoverCategoryLevelOne"/>
42+
<moveMouseOver
43+
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category2.name$$)}}"
44+
stepKey="hoverCategoryLevelTwo"/>
45+
<moveMouseOver
46+
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category3.name$$)}}"
47+
stepKey="hoverCategoryLevelThree"/>
48+
<moveMouseOver
49+
selector="{{StorefrontHeaderSection.NavigationCategoryByName($$category4.name$$)}}"
50+
stepKey="hoverCategoryLevelFour"/>
51+
</test>
52+
</tests>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Unit\Model\Product\Image;
8+
9+
use Magento\Catalog\Model\Product\Image;
10+
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
11+
use Magento\Framework\App\Area;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\Config\View;
14+
use Magento\Framework\View\ConfigInterface;
15+
use Magento\Store\Model\ScopeInterface;
16+
17+
class ParamsBuilderTest extends \PHPUnit\Framework\TestCase
18+
{
19+
/**
20+
* @var ScopeConfigInterface
21+
*/
22+
private $scopeConfig;
23+
24+
/**
25+
* @var ConfigInterface
26+
*/
27+
private $viewConfig;
28+
29+
/**
30+
* @var ParamsBuilder
31+
*/
32+
private $model;
33+
34+
protected function setUp()
35+
{
36+
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
37+
$this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
38+
$this->viewConfig = $this->createMock(ConfigInterface::class);
39+
$this->model = $objectManager->getObject(
40+
ParamsBuilder::class,
41+
[
42+
'scopeConfig' => $this->scopeConfig,
43+
'viewConfig' => $this->viewConfig,
44+
]
45+
);
46+
}
47+
48+
/**
49+
* Test watermark location.
50+
*/
51+
public function testWatermarkLocation()
52+
{
53+
$imageArguments = [
54+
'type' => 'type',
55+
'height' => 'image_height',
56+
'width' => 'image_width',
57+
'angle' => 'angle',
58+
'background' => [1, 2, 3]
59+
];
60+
$scopeId = 1;
61+
$quality = 100;
62+
$file = 'file';
63+
$width = 'width';
64+
$height = 'height';
65+
$size = "{$width}x{$height}";
66+
$opacity = 'opacity';
67+
$position = 'position';
68+
69+
$viewMock = $this->createMock(View::class);
70+
$viewMock->expects($this->once())
71+
->method('getVarValue')
72+
->with('Magento_Catalog', 'product_image_white_borders')
73+
->willReturn(true);
74+
75+
$this->viewConfig->expects($this->once())
76+
->method('getViewConfig')
77+
->with(['area' => Area::AREA_FRONTEND])
78+
->willReturn($viewMock);
79+
80+
$this->scopeConfig->expects($this->exactly(5))->method('getValue')->withConsecutive(
81+
[
82+
Image::XML_PATH_JPEG_QUALITY
83+
],
84+
[
85+
"design/watermark/{$imageArguments['type']}_image",
86+
ScopeInterface::SCOPE_STORE,
87+
$scopeId,
88+
],
89+
[
90+
"design/watermark/{$imageArguments['type']}_size",
91+
ScopeInterface::SCOPE_STORE],
92+
[
93+
"design/watermark/{$imageArguments['type']}_imageOpacity",
94+
ScopeInterface::SCOPE_STORE,
95+
$scopeId
96+
],
97+
[
98+
"design/watermark/{$imageArguments['type']}_position",
99+
ScopeInterface::SCOPE_STORE,
100+
$scopeId
101+
]
102+
)->willReturnOnConsecutiveCalls(
103+
$quality,
104+
$file,
105+
$size,
106+
$opacity,
107+
$position
108+
);
109+
110+
$actual = $this->model->build($imageArguments, $scopeId);
111+
$expected = [
112+
'image_type' => $imageArguments['type'],
113+
'background' => $imageArguments['background'],
114+
'angle' => $imageArguments['angle'],
115+
'quality' => $quality,
116+
'keep_aspect_ratio' => true,
117+
'keep_frame' => true,
118+
'keep_transparency' => true,
119+
'constrain_only' => true,
120+
'watermark_file' => $file,
121+
'watermark_image_opacity' => $opacity,
122+
'watermark_position' => $position,
123+
'watermark_width' => $width,
124+
'watermark_height' => $height,
125+
'image_height' => $imageArguments['height'],
126+
'image_width' => $imageArguments['width'],
127+
];
128+
129+
$this->assertEquals(
130+
$expected,
131+
$actual
132+
);
133+
}
134+
}

app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<element name="goToCheckout" type="button" selector="#top-cart-btn-checkout" timeout="30"/>
2626
<element name="viewAndEditCart" type="button" selector=".action.viewcart" timeout="30"/>
2727
<element name="miniCartItemsText" type="text" selector=".minicart-items"/>
28+
<element name="editMiniCartItem" type="button" selector=".action.edit" timeout="30"/>
2829
<element name="deleteMiniCartItem" type="button" selector=".action.delete" timeout="30"/>
2930
<element name="deleteMiniCartItemByName" type="button" selector="//ol[@id='mini-cart']//div[contains(., '{{var}}')]//a[contains(@class, 'delete')]" parameterized="true"/>
3031
<element name="miniCartSubtotalField" type="text" selector=".block-minicart .amount span.price"/>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="NoErrorForMiniCartItemEditTest">
12+
<annotations>
13+
<features value="ConfigurableProduct"/>
14+
<title value="No error for minicart item edit test"/>
15+
<description value="Already selected configurable option should be selected when configurable product is edited from minicart"/>
16+
<severity value="MAJOR"/>
17+
<group value="ConfigurableProduct"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
21+
<createData entity="ApiCategory" stepKey="createCategory"/>
22+
<!-- Create Configurable product -->
23+
<actionGroup ref="createConfigurableProduct" stepKey="createProduct">
24+
<argument name="product" value="_defaultProduct"/>
25+
<argument name="category" value="$$createCategory$$"/>
26+
</actionGroup>
27+
</before>
28+
<after>
29+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
30+
<!-- Delete the first simple product -->
31+
<actionGroup stepKey="deleteProduct1" ref="deleteProductBySku">
32+
<argument name="sku" value="{{_defaultProduct.sku}}"/>
33+
</actionGroup>
34+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}"
35+
dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true"
36+
stepKey="clickClearFilters"/>
37+
<actionGroup ref="logout" stepKey="logout"/>
38+
</after>
39+
40+
<!-- Go To Created Product Page -->
41+
<amOnPage stepKey="goToCreatedProductPage" url="{{_defaultProduct.urlKey}}.html"/>
42+
<waitForPageLoad stepKey="waitForProductPageLoad2"/>
43+
44+
<!-- Add Product to Cart -->
45+
<seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}"
46+
stepKey="checkDropDownProductOption"/>
47+
<selectOption userInput="{{colorProductAttribute1.name}}"
48+
selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
49+
stepKey="selectOption1"/>
50+
<selectOption userInput="{{colorProductAttribute2.name}}"
51+
selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
52+
stepKey="selectOption2"/>
53+
<click selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}"
54+
stepKey="clickDropDownProductOption"/>
55+
<selectOption userInput="{{colorProductAttribute1.name}}"
56+
selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
57+
stepKey="selectOptionForAddingToCart"/>
58+
<click selector="{{StorefrontProductInfoMainSection.AddToCart}}" stepKey="clickAddToCart"/>
59+
<waitForPageLoad stepKey="waitForMiniCart"/>
60+
61+
<!-- Edit Item in Cart -->
62+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart"/>
63+
<click selector="{{StorefrontMinicartSection.editMiniCartItem}}" stepKey="clickEditCartItem"/>
64+
65+
<!-- Check if Product Configuration is still selected -->
66+
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}"
67+
userInput="{{colorProductAttribute1.name}}" stepKey="seeConfigurationSelected"/>
68+
</test>
69+
</tests>

lib/internal/Magento/Framework/App/Test/Unit/FrontControllerTest.php

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Framework\App\Test\Unit;
78

9+
use Magento\Framework\App\Request\InvalidRequestException;
10+
use Magento\Framework\App\Request\ValidatorInterface;
811
use Magento\Framework\Exception\NotFoundException;
12+
use Magento\Framework\Message\ManagerInterface as MessageManager;
13+
use Psr\Log\LoggerInterface;
914

15+
/**
16+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
*/
1018
class FrontControllerTest extends \PHPUnit\Framework\TestCase
1119
{
1220
/**
@@ -34,6 +42,21 @@ class FrontControllerTest extends \PHPUnit\Framework\TestCase
3442
*/
3543
protected $response;
3644

45+
/**
46+
* @var \PHPUnit\Framework\MockObject\MockObject|ValidatorInterface
47+
*/
48+
private $requestValidator;
49+
50+
/**
51+
* @var \PHPUnit\Framework\MockObject\MockObject|\MessageManager
52+
*/
53+
private $messages;
54+
55+
/**
56+
* @var \PHPUnit\Framework\MockObject\MockObject|\LoggerInterface
57+
*/
58+
private $logger;
59+
3760
protected function setUp()
3861
{
3962
$this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
@@ -44,7 +67,16 @@ protected function setUp()
4467
$this->router = $this->createMock(\Magento\Framework\App\RouterInterface::class);
4568
$this->routerList = $this->createMock(\Magento\Framework\App\RouterList::class);
4669
$this->response = $this->createMock(\Magento\Framework\App\Response\Http::class);
47-
$this->model = new \Magento\Framework\App\FrontController($this->routerList, $this->response);
70+
$this->requestValidator = $this->createMock(ValidatorInterface::class);
71+
$this->messages = $this->createMock(MessageManager::class);
72+
$this->logger = $this->createMock(LoggerInterface::class);
73+
$this->model = new \Magento\Framework\App\FrontController(
74+
$this->routerList,
75+
$this->response,
76+
$this->requestValidator,
77+
$this->messages,
78+
$this->logger
79+
);
4880
}
4981

5082
/**
@@ -55,7 +87,8 @@ public function testDispatchThrowException()
5587
{
5688
$validCounter = 0;
5789
$callbackValid = function () use (&$validCounter) {
58-
return $validCounter++%10 ? false : true;
90+
$validCounter++;
91+
return $validCounter % 10 ? false : true;
5992
};
6093
$this->routerList->expects($this->any())->method('valid')->will($this->returnCallback($callbackValid));
6194

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

109+
/**
110+
* Check adding validation failure message to debug log.
111+
*/
112+
public function testAddingValidationFailureMessageToDebugLog()
113+
{
114+
$exceptionMessage = 'exception_message';
115+
$exception = new InvalidRequestException($exceptionMessage);
116+
117+
$this->routerList->expects($this->any())
118+
->method('valid')
119+
->will($this->returnValue(true));
120+
121+
$response = $this->createMock(\Magento\Framework\App\Response\Http::class);
122+
$controllerInstance = $this->getMockBuilder(\Magento\Framework\App\Action\Action::class)
123+
->disableOriginalConstructor()
124+
->getMock();
125+
$controllerInstance->expects($this->any())
126+
->method('dispatch')
127+
->with($this->request)
128+
->will($this->returnValue($response));
129+
$this->router->expects($this->at(0))
130+
->method('match')
131+
->with($this->request)
132+
->will($this->returnValue(false));
133+
$this->router->expects($this->at(1))
134+
->method('match')
135+
->with($this->request)
136+
->will($this->returnValue($controllerInstance));
137+
138+
$this->routerList->expects($this->any())
139+
->method('current')
140+
->will($this->returnValue($this->router));
141+
142+
$this->request->expects($this->at(0))->method('isDispatched')->will($this->returnValue(false));
143+
$this->request->expects($this->at(1))->method('setDispatched')->with(true);
144+
$this->request->expects($this->at(2))->method('isDispatched')->will($this->returnValue(true));
145+
146+
$this->requestValidator->expects($this->once())
147+
->method('validate')->with($this->request, $controllerInstance)->willThrowException($exception);
148+
$this->logger->expects($this->once())->method('debug')->with(
149+
'Request validation failed for action "'
150+
. get_class($controllerInstance) . '"',
151+
["exception" => $exception]
152+
);
153+
154+
$this->assertEquals($exceptionMessage, $this->model->dispatch($this->request));
155+
}
156+
76157
public function testDispatched()
77158
{
78159
$this->routerList->expects($this->any())

0 commit comments

Comments
 (0)