Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - magento#21156: [Backport] [SendFriend] Covering the Send to friend by integration tests (by @eduard13)
 - magento#21155: [Backport] [Checkout] Covering the successfully adding a valid coupon to cart by an integra… (by @eduard13)
 - magento#20821: [Backport] Fixing the styling issue on customizable options (by @eduard13)


Fixed GitHub Issues:
 - magento#20497: Product customizable options issue (reported by @eduard13) has been fixed in magento#20821 by @eduard13 in 2.2-develop branch
   Related commits:
     1. 06f7430
  • Loading branch information
magento-engcom-team authored Feb 12, 2019
2 parents ae2090c + f6ecf31 commit a951912
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@
&.collapsible-block-wrapper-last {
border-bottom: 0;
}

.admin__dynamic-rows.admin__control-collapsible {
td {
&.admin__collapsible-block-wrapper {
border-bottom: none;
}
}
}
}

.admin__collapsible-content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Magento\Checkout\Controller\Cart\Index;

use Magento\Framework\App\Request\Http as HttpRequest;

/**
* @magentoDbIsolation enabled
*/
Expand Down Expand Up @@ -36,4 +38,35 @@ public function testExecute()
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
}

/**
* Testing by adding a valid coupon to cart
*
* @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
* @magentoDataFixture Magento/Usps/Fixtures/cart_rule_coupon_free_shipping.php
* @return void
*/
public function testAddingValidCoupon()
{
/** @var $session \Magento\Checkout\Model\Session */
$session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
$quote = $session->getQuote();
$quote->setData('trigger_recollect', 1)->setTotalsCollectedFlag(true);

$couponCode = 'IMPHBR852R61';
$inputData = [
'remove' => 0,
'coupon_code' => $couponCode
];
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($inputData);
$this->dispatch(
'checkout/cart/couponPost/'
);

$this->assertSessionMessages(
$this->equalTo(['You used coupon code "' . $couponCode . '".']),
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\SendFriend\Controller;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Customer\Model\Session;
use Magento\Framework\Data\Form\FormKey;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\Request;
use Magento\TestFramework\TestCase\AbstractController;

/**
* Class SendmailTest
*/
class SendmailTest extends AbstractController
{
/**
* Share the product to friend as logged in customer
*
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/SendFriend/_files/disable_allow_guest_config.php
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDataFixture Magento/Catalog/_files/products.php
*/
public function testSendActionAsLoggedIn()
{
$product = $this->getProduct();
$this->login(1);
$this->prepareRequestData();

$this->dispatch('sendfriend/product/sendmail/id/' . $product->getId());
$this->assertSessionMessages(
$this->equalTo(['The link to a friend was sent.']),
MessageInterface::TYPE_SUCCESS
);
}

/**
* Share the product to friend as guest customer
*
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture default_store sendfriend/email/enabled 1
* @magentoConfigFixture default_store sendfriend/email/allow_guest 1
* @magentoDataFixture Magento/Catalog/_files/products.php
*/
public function testSendActionAsGuest()
{
$product = $this->getProduct();
$this->prepareRequestData();

$this->dispatch('sendfriend/product/sendmail/id/' . $product->getId());
$this->assertSessionMessages(
$this->equalTo(['The link to a friend was sent.']),
MessageInterface::TYPE_SUCCESS
);
}

/**
* Share the product to friend as guest customer with invalid post data
*
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture default_store sendfriend/email/enabled 1
* @magentoConfigFixture default_store sendfriend/email/allow_guest 1
* @magentoDataFixture Magento/Catalog/_files/products.php
*/
public function testSendActionAsGuestWithInvalidData()
{
$product = $this->getProduct();
$this->prepareRequestData(true);

$this->dispatch('sendfriend/product/sendmail/id/' . $product->getId());
$this->assertSessionMessages(
$this->equalTo(['Invalid Sender Email']),
MessageInterface::TYPE_ERROR
);
}

/**
* @return ProductInterface
*/
private function getProduct()
{
return $this->_objectManager->get(ProductRepositoryInterface::class)->get('custom-design-simple-product');
}

/**
* Login the user
*
* @param string $customerId Customer to mark as logged in for the session
* @return void
*/
protected function login($customerId)
{
/** @var Session $session */
$session = Bootstrap::getObjectManager()
->get(Session::class);
$session->loginById($customerId);
}

/**
* @param bool $invalidData
* @return void
*/
private function prepareRequestData($invalidData = false)
{
/** @var FormKey $formKey */
$formKey = $this->_objectManager->get(FormKey::class);
$post = [
'sender' => [
'name' => 'Test',
'email' => 'test@example.com',
'message' => 'Message',
],
'recipients' => [
'name' => [
'Recipient 1',
'Recipient 2'
],
'email' => [
'r1@example.com',
'r2@example.com'
]
],
'form_key' => $formKey->getFormKey(),
];
if ($invalidData) {
unset($post['sender']['email']);
}

$this->getRequest()->setMethod(Request::METHOD_POST);
$this->getRequest()->setPostValue($post);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

use Magento\Framework\App\Config\Value;
use Magento\TestFramework\Helper\Bootstrap;

/** @var Value $config */
$config = Bootstrap::getObjectManager()->create(Value::class);
$config->setPath('sendfriend/email/enabled');
$config->setScope('default');
$config->setScopeId(0);
$config->setValue(1);
$config->save();

/** @var Value $config */
$config = Bootstrap::getObjectManager()->create(Value::class);
$config->setPath('sendfriend/email/allow_guest');
$config->setScope('default');
$config->setScopeId(0);
$config->setValue(0);
$config->save();

0 comments on commit a951912

Please sign in to comment.