Skip to content

Commit a951912

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #21156: [Backport] [SendFriend] Covering the Send to friend by integration tests (by @eduard13) - #21155: [Backport] [Checkout] Covering the successfully adding a valid coupon to cart by an integra… (by @eduard13) - #20821: [Backport] Fixing the styling issue on customizable options (by @eduard13) Fixed GitHub Issues: - #20497: Product customizable options issue (reported by @eduard13) has been fixed in #20821 by @eduard13 in 2.2-develop branch Related commits: 1. 06f7430
2 parents ae2090c + f6ecf31 commit a951912

File tree

4 files changed

+208
-0
lines changed

4 files changed

+208
-0
lines changed

app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@
163163
&.collapsible-block-wrapper-last {
164164
border-bottom: 0;
165165
}
166+
167+
.admin__dynamic-rows.admin__control-collapsible {
168+
td {
169+
&.admin__collapsible-block-wrapper {
170+
border-bottom: none;
171+
}
172+
}
173+
}
166174
}
167175

168176
.admin__collapsible-content {

dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Checkout\Controller\Cart\Index;
88

9+
use Magento\Framework\App\Request\Http as HttpRequest;
10+
911
/**
1012
* @magentoDbIsolation enabled
1113
*/
@@ -36,4 +38,35 @@ public function testExecute()
3638
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
3739
);
3840
}
41+
42+
/**
43+
* Testing by adding a valid coupon to cart
44+
*
45+
* @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
46+
* @magentoDataFixture Magento/Usps/Fixtures/cart_rule_coupon_free_shipping.php
47+
* @return void
48+
*/
49+
public function testAddingValidCoupon()
50+
{
51+
/** @var $session \Magento\Checkout\Model\Session */
52+
$session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
53+
$quote = $session->getQuote();
54+
$quote->setData('trigger_recollect', 1)->setTotalsCollectedFlag(true);
55+
56+
$couponCode = 'IMPHBR852R61';
57+
$inputData = [
58+
'remove' => 0,
59+
'coupon_code' => $couponCode
60+
];
61+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
62+
$this->getRequest()->setPostValue($inputData);
63+
$this->dispatch(
64+
'checkout/cart/couponPost/'
65+
);
66+
67+
$this->assertSessionMessages(
68+
$this->equalTo(['You used coupon code "' . $couponCode . '".']),
69+
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
70+
);
71+
}
3972
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\SendFriend\Controller;
9+
10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Catalog\Api\ProductRepositoryInterface;
12+
use Magento\Customer\Model\Session;
13+
use Magento\Framework\Data\Form\FormKey;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use Magento\Framework\Message\MessageInterface;
16+
use Magento\TestFramework\Request;
17+
use Magento\TestFramework\TestCase\AbstractController;
18+
19+
/**
20+
* Class SendmailTest
21+
*/
22+
class SendmailTest extends AbstractController
23+
{
24+
/**
25+
* Share the product to friend as logged in customer
26+
*
27+
* @magentoDbIsolation enabled
28+
* @magentoAppIsolation enabled
29+
* @magentoDataFixture Magento/SendFriend/_files/disable_allow_guest_config.php
30+
* @magentoDataFixture Magento/Customer/_files/customer.php
31+
* @magentoDataFixture Magento/Catalog/_files/products.php
32+
*/
33+
public function testSendActionAsLoggedIn()
34+
{
35+
$product = $this->getProduct();
36+
$this->login(1);
37+
$this->prepareRequestData();
38+
39+
$this->dispatch('sendfriend/product/sendmail/id/' . $product->getId());
40+
$this->assertSessionMessages(
41+
$this->equalTo(['The link to a friend was sent.']),
42+
MessageInterface::TYPE_SUCCESS
43+
);
44+
}
45+
46+
/**
47+
* Share the product to friend as guest customer
48+
*
49+
* @magentoDbIsolation enabled
50+
* @magentoAppIsolation enabled
51+
* @magentoConfigFixture default_store sendfriend/email/enabled 1
52+
* @magentoConfigFixture default_store sendfriend/email/allow_guest 1
53+
* @magentoDataFixture Magento/Catalog/_files/products.php
54+
*/
55+
public function testSendActionAsGuest()
56+
{
57+
$product = $this->getProduct();
58+
$this->prepareRequestData();
59+
60+
$this->dispatch('sendfriend/product/sendmail/id/' . $product->getId());
61+
$this->assertSessionMessages(
62+
$this->equalTo(['The link to a friend was sent.']),
63+
MessageInterface::TYPE_SUCCESS
64+
);
65+
}
66+
67+
/**
68+
* Share the product to friend as guest customer with invalid post data
69+
*
70+
* @magentoDbIsolation enabled
71+
* @magentoAppIsolation enabled
72+
* @magentoConfigFixture default_store sendfriend/email/enabled 1
73+
* @magentoConfigFixture default_store sendfriend/email/allow_guest 1
74+
* @magentoDataFixture Magento/Catalog/_files/products.php
75+
*/
76+
public function testSendActionAsGuestWithInvalidData()
77+
{
78+
$product = $this->getProduct();
79+
$this->prepareRequestData(true);
80+
81+
$this->dispatch('sendfriend/product/sendmail/id/' . $product->getId());
82+
$this->assertSessionMessages(
83+
$this->equalTo(['Invalid Sender Email']),
84+
MessageInterface::TYPE_ERROR
85+
);
86+
}
87+
88+
/**
89+
* @return ProductInterface
90+
*/
91+
private function getProduct()
92+
{
93+
return $this->_objectManager->get(ProductRepositoryInterface::class)->get('custom-design-simple-product');
94+
}
95+
96+
/**
97+
* Login the user
98+
*
99+
* @param string $customerId Customer to mark as logged in for the session
100+
* @return void
101+
*/
102+
protected function login($customerId)
103+
{
104+
/** @var Session $session */
105+
$session = Bootstrap::getObjectManager()
106+
->get(Session::class);
107+
$session->loginById($customerId);
108+
}
109+
110+
/**
111+
* @param bool $invalidData
112+
* @return void
113+
*/
114+
private function prepareRequestData($invalidData = false)
115+
{
116+
/** @var FormKey $formKey */
117+
$formKey = $this->_objectManager->get(FormKey::class);
118+
$post = [
119+
'sender' => [
120+
'name' => 'Test',
121+
'email' => 'test@example.com',
122+
'message' => 'Message',
123+
],
124+
'recipients' => [
125+
'name' => [
126+
'Recipient 1',
127+
'Recipient 2'
128+
],
129+
'email' => [
130+
'r1@example.com',
131+
'r2@example.com'
132+
]
133+
],
134+
'form_key' => $formKey->getFormKey(),
135+
];
136+
if ($invalidData) {
137+
unset($post['sender']['email']);
138+
}
139+
140+
$this->getRequest()->setMethod(Request::METHOD_POST);
141+
$this->getRequest()->setPostValue($post);
142+
}
143+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Framework\App\Config\Value;
8+
use Magento\TestFramework\Helper\Bootstrap;
9+
10+
/** @var Value $config */
11+
$config = Bootstrap::getObjectManager()->create(Value::class);
12+
$config->setPath('sendfriend/email/enabled');
13+
$config->setScope('default');
14+
$config->setScopeId(0);
15+
$config->setValue(1);
16+
$config->save();
17+
18+
/** @var Value $config */
19+
$config = Bootstrap::getObjectManager()->create(Value::class);
20+
$config->setPath('sendfriend/email/allow_guest');
21+
$config->setScope('default');
22+
$config->setScopeId(0);
23+
$config->setValue(0);
24+
$config->save();

0 commit comments

Comments
 (0)