Skip to content

Commit 359f60f

Browse files
committed
Merge branch 'pr36' into NORD-EXT-PR-36
2 parents d844e31 + 94e8971 commit 359f60f

File tree

9 files changed

+349
-0
lines changed

9 files changed

+349
-0
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,26 @@ public function getFormattedAddress(Address $address)
303303
{
304304
return $this->addressRenderer->format($address, 'html');
305305
}
306+
307+
/**
308+
* @inheritdoc
309+
*/
310+
public function getChildHtml($alias = '', $useCache = true)
311+
{
312+
$layout = $this->getLayout();
313+
314+
if ($alias || !$layout) {
315+
return parent::getChildHtml($alias, $useCache);
316+
}
317+
318+
$childNames = $layout->getChildNames($this->getNameInLayout());
319+
$outputChildNames = array_diff($childNames, ['extra_customer_info']);
320+
321+
$out = '';
322+
foreach ($outputChildNames as $childName) {
323+
$out .= $layout->renderElement($childName, $useCache);
324+
}
325+
326+
return $out;
327+
}
306328
}
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+
namespace Magento\Bundle\Api;
7+
8+
/**
9+
* API test for creation of Invoice for order with bundle product.
10+
*/
11+
class OrderInvoiceCreateTest extends \Magento\TestFramework\TestCase\WebapiAbstract
12+
{
13+
const SERVICE_READ_NAME = 'salesInvoiceOrderV1';
14+
const SERVICE_VERSION = 'V1';
15+
16+
/**
17+
* @var \Magento\Framework\ObjectManagerInterface
18+
*/
19+
private $objectManager;
20+
21+
/**
22+
* @var \Magento\Sales\Api\InvoiceRepositoryInterface
23+
*/
24+
private $invoiceRepository;
25+
26+
/**
27+
* Set up.
28+
*
29+
* @return void
30+
*/
31+
protected function setUp()
32+
{
33+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
34+
$this->invoiceRepository = $this->objectManager->get(
35+
\Magento\Sales\Api\InvoiceRepositoryInterface::class
36+
);
37+
}
38+
39+
/**
40+
* Test create a partial invoice for order with bundle and Simple products.
41+
*
42+
* @return void
43+
* @magentoApiDataFixture Magento/Bundle/_files/order_items_simple_and_bundle.php
44+
*/
45+
public function testInvoiceWithSimpleAndBundleCreate()
46+
{
47+
/** @var \Magento\Sales\Api\Data\OrderInterface $existingOrder*/
48+
$existingOrder = $this->objectManager->create(\Magento\Sales\Api\Data\OrderInterface::class)
49+
->loadByIncrementId('100000001');
50+
51+
$serviceInfo = [
52+
'rest' => [
53+
'resourcePath' => '/V1/order/' . $existingOrder->getId() . '/invoice',
54+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
55+
],
56+
'soap' => [
57+
'service' => self::SERVICE_READ_NAME,
58+
'serviceVersion' => self::SERVICE_VERSION,
59+
'operation' => self::SERVICE_READ_NAME . 'execute',
60+
],
61+
];
62+
63+
$requestData = [
64+
'orderId' => $existingOrder->getId(),
65+
'items' => [],
66+
'comment' => [
67+
'comment' => 'Test Comment',
68+
'is_visible_on_front' => 1,
69+
],
70+
];
71+
$grantTotal = 0;
72+
foreach ($existingOrder->getAllItems() as $item) {
73+
$requestData['items'] = [];
74+
$requestData['items'][] = [
75+
'order_item_id' => $item->getItemId(),
76+
'qty' => $item->getQtyOrdered(),
77+
];
78+
$result = $this->_webApiCall($serviceInfo, $requestData);
79+
$this->assertNotEmpty($result);
80+
try {
81+
$invoice = $this->invoiceRepository->get($result);
82+
$grantTotal += $invoice->getGrandTotal();
83+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
84+
$this->fail('Failed asserting that Invoice was created');
85+
}
86+
}
87+
$this->assertNotEquals(
88+
$existingOrder->getGrandTotal(),
89+
$grantTotal,
90+
'Failed asserting that invoice is correct.'
91+
);
92+
}
93+
94+
/**
95+
* Test create invoice with Bundle product.
96+
*
97+
* @return void
98+
* @magentoApiDataFixture Magento/Bundle/_files/order_item_with_bundle_and_options.php
99+
*/
100+
public function testInvoiceWithBundleCreate()
101+
{
102+
/** @var \Magento\Sales\Api\Data\OrderInterface $existingOrder*/
103+
$existingOrder = $this->objectManager->create(\Magento\Sales\Api\Data\OrderInterface::class)
104+
->loadByIncrementId('100000001');
105+
106+
$serviceInfo = [
107+
'rest' => [
108+
'resourcePath' => '/V1/order/' . $existingOrder->getId() . '/invoice',
109+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
110+
],
111+
'soap' => [
112+
'service' => self::SERVICE_READ_NAME,
113+
'serviceVersion' => self::SERVICE_VERSION,
114+
'operation' => self::SERVICE_READ_NAME . 'execute',
115+
],
116+
];
117+
118+
$requestData = [
119+
'orderId' => $existingOrder->getId(),
120+
'items' => [],
121+
'comment' => [
122+
'comment' => 'Test Comment',
123+
'is_visible_on_front' => 1,
124+
],
125+
];
126+
127+
/** @var \Magento\Sales\Api\Data\OrderItemInterface $item */
128+
foreach ($existingOrder->getAllItems() as $item) {
129+
$requestData['items'][] = [
130+
'order_item_id' => $item->getItemId(),
131+
'qty' => $item->getQtyOrdered(),
132+
];
133+
}
134+
$result = $this->_webApiCall($serviceInfo, $requestData);
135+
$this->assertNotEmpty($result);
136+
$invoice = $this->invoiceRepository->get($result);
137+
$this->assertNotEquals(
138+
$existingOrder->getGrandTotal(),
139+
$invoice->getGrandTotal(),
140+
'Failed asserting that invoice is correct.'
141+
);
142+
}
143+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Mtf\Client\Element\SimpleElement;
1111
use Magento\Ui\Test\Block\Adminhtml\Section;
1212
use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\AbstractOptions;
13+
use Magento\Mtf\Client\Locator;
1314

1415
/**
1516
* Product advanced pricing section.
@@ -37,6 +38,13 @@ class AdvancedPricing extends Section
3738
*/
3839
protected $doneButton = '.action-primary[data-role="action"]';
3940

41+
/**
42+
* Selector for field.
43+
*
44+
* @var string
45+
*/
46+
private $fieldByName = '//*[contains(text(),"%s")]/preceding::div[2]/ancestor::div[1]';
47+
4048
/**
4149
* Fill 'Advanced price' product form on tab.
4250
*
@@ -104,4 +112,15 @@ public function getTierPriceForm(SimpleElement $element = null)
104112
['element' => $element]
105113
);
106114
}
115+
116+
/**
117+
* Check if the field is displayed correctly.
118+
*
119+
* @param string $fieldName
120+
* @return bool
121+
*/
122+
public function checkField($fieldName)
123+
{
124+
return $this->_rootElement->find(sprintf($this->fieldByName, $fieldName), Locator::SELECTOR_XPATH)->isVisible();
125+
}
107126
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Msrp\Test\Constraint;
8+
9+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\Mtf\Fixture\FixtureInterface;
12+
13+
/**
14+
* Check "Manufacturer's Suggested Retail Price" field on "Advanced pricing" page.
15+
*/
16+
class AssertProductEditPageAdvancedPricingFields extends AbstractConstraint
17+
{
18+
/**
19+
* Title of "Manufacturer's Suggested Retail Price" field.
20+
*
21+
* @var string
22+
*/
23+
private $manufacturerFieldTitle = 'Manufacturer\'s Suggested Retail Price';
24+
25+
/**
26+
* @param CatalogProductEdit $catalogProductEdit
27+
* @param FixtureInterface $product
28+
* @return void
29+
*/
30+
public function processAssert(CatalogProductEdit $catalogProductEdit, FixtureInterface $product)
31+
{
32+
$catalogProductEdit->open(['id' => $product->getId()]);
33+
$catalogProductEdit->getProductForm()->openSection('advanced-pricing');
34+
$advancedPricing = $catalogProductEdit->getProductForm()->getSection('advanced-pricing');
35+
36+
\PHPUnit_Framework_Assert::assertTrue(
37+
$advancedPricing->checkField($this->manufacturerFieldTitle),
38+
'"Manufacturer\'s Suggested Retail Price" field is not correct.'
39+
);
40+
}
41+
42+
/**
43+
* Returns a string representation of the object.
44+
*
45+
* @return string
46+
*/
47+
public function toString()
48+
{
49+
return '"Manufacturer\'s Suggested Retail Price" field is correct.';
50+
}
51+
}

dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@
4646
<constraint name="Magento\Msrp\Test\Constraint\AssertMapOnProductView" />
4747
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpInShoppingCart" />
4848
</variation>
49+
<variation name="ApplyMapTestVariation6" summary="[Catalog] MSRP field is not displayed for bundle products with fixed price" ticketId="MAGETWO-63054">
50+
<data name="product" xsi:type="string">bundleProduct::bundle_fixed_product</data>
51+
<constraint name="Magento\Msrp\Test\Constraint\AssertProductEditPageAdvancedPricingFields" />
52+
</variation>
4953
</testCase>
5054
</config>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
require __DIR__ . '/order_item_with_bundle_and_options.php';
8+
require __DIR__ . '/../../../Magento/Catalog/_files/category_product.php';
9+
10+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
11+
12+
/** @var \Magento\Sales\Model\Order\Item $orderItem */
13+
$orderItem = $objectManager->create(\Magento\Sales\Model\Order\Item::class);
14+
/** @var $product \Magento\Catalog\Model\Product */
15+
$orderItem->setProductId($product->getId())->setQtyOrdered(1);
16+
$orderItem->setBasePrice($product->getPrice());
17+
$orderItem->setPrice($product->getPrice());
18+
$orderItem->setRowTotal($product->getPrice());
19+
$orderItem->setProductType('simple');
20+
21+
/** @var \Magento\Sales\Model\Order $order */
22+
$order->addItem($orderItem);
23+
$order->save();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
require __DIR__ . '/../../../Magento/Catalog/_files/category_product_rollback.php';
8+
require __DIR__ . '/product_with_multiple_options_rollback.php';
9+
require __DIR__ . '/../../../Magento/Sales/_files/default_rollback.php';

dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,38 @@ public function testLogoutAction()
6464
$this->assertRedirect($this->stringContains('customer/account/logoutSuccess'));
6565
}
6666

67+
/**
68+
* Test that forgot password email message displays special characters correctly.
69+
*
70+
* @magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 0
71+
* @magentoConfigFixture current_store customer/password/forgot_email_template customer_password_forgot_email_template
72+
* @magentoConfigFixture current_store customer/password/forgot_email_identity support
73+
* @magentoConfigFixture current_store general/store_information/name Test special' characters
74+
* @magentoDataFixture Magento/Customer/_files/customer.php
75+
*/
76+
public function testForgotPasswordEmailMessageWithSpecialCharacters()
77+
{
78+
$email = 'customer@example.com';
79+
80+
$this->getRequest()
81+
->setPostValue([
82+
'email' => $email,
83+
]);
84+
85+
$this->dispatch('customer/account/forgotPasswordPost');
86+
$this->assertRedirect($this->stringContains('customer/account/'));
87+
88+
/** @var \Magento\TestFramework\Mail\Template\TransportBuilderMock $transportBuilder */
89+
$transportBuilder = $this->_objectManager->get(
90+
\Magento\TestFramework\Mail\Template\TransportBuilderMock::class
91+
);
92+
$subject = $transportBuilder->getSentMessage()->getSubject();
93+
$this->assertContains(
94+
'Test special\' characters',
95+
$subject
96+
);
97+
}
98+
6799
/**
68100
* @magentoDataFixture Magento/Customer/_files/customer.php
69101
*/
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Store\Block;
7+
8+
/**
9+
* Integration tests for \Magento\Store\Block\Switcher block.
10+
*/
11+
class SwitcherTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\TestFramework\ObjectManager
15+
*/
16+
private $_objectManager;
17+
18+
/**
19+
* Set up.
20+
*
21+
* @return void
22+
*/
23+
protected function setUp()
24+
{
25+
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
26+
}
27+
28+
/**
29+
* Test that GetTargetStorePostData() method return correct store URL.
30+
*
31+
* @magentoDataFixture Magento/Store/_files/store.php
32+
* @return void
33+
*/
34+
public function testGetTargetStorePostData()
35+
{
36+
$storeCode = 'test';
37+
/** @var \Magento\Store\Block\Switcher $block */
38+
$block = $this->_objectManager->create(\Magento\Store\Block\Switcher::class);
39+
/** @var \Magento\Store\Api\StoreRepositoryInterface $storeRepository */
40+
$storeRepository = $this->_objectManager->create(\Magento\Store\Api\StoreRepositoryInterface::class);
41+
$store = $storeRepository->get($storeCode);
42+
$result = json_decode($block->getTargetStorePostData($store), true);
43+
44+
$this->assertContains($storeCode, $result['action']);
45+
}
46+
}

0 commit comments

Comments
 (0)