diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php index a86d33a9ad762..0ff22646e1935 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php @@ -303,4 +303,26 @@ public function getFormattedAddress(Address $address) { return $this->addressRenderer->format($address, 'html'); } + + /** + * @inheritdoc + */ + public function getChildHtml($alias = '', $useCache = true) + { + $layout = $this->getLayout(); + + if ($alias || !$layout) { + return parent::getChildHtml($alias, $useCache); + } + + $childNames = $layout->getChildNames($this->getNameInLayout()); + $outputChildNames = array_diff($childNames, ['extra_customer_info']); + + $out = ''; + foreach ($outputChildNames as $childName) { + $out .= $layout->renderElement($childName, $useCache); + } + + return $out; + } } diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderInvoiceCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderInvoiceCreateTest.php new file mode 100644 index 0000000000000..3a40e510326a4 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderInvoiceCreateTest.php @@ -0,0 +1,143 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->invoiceRepository = $this->objectManager->get( + \Magento\Sales\Api\InvoiceRepositoryInterface::class + ); + } + + /** + * Test create a partial invoice for order with bundle and Simple products. + * + * @return void + * @magentoApiDataFixture Magento/Bundle/_files/order_items_simple_and_bundle.php + */ + public function testInvoiceWithSimpleAndBundleCreate() + { + /** @var \Magento\Sales\Api\Data\OrderInterface $existingOrder*/ + $existingOrder = $this->objectManager->create(\Magento\Sales\Api\Data\OrderInterface::class) + ->loadByIncrementId('100000001'); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/order/' . $existingOrder->getId() . '/invoice', + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + ], + 'soap' => [ + 'service' => self::SERVICE_READ_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_READ_NAME . 'execute', + ], + ]; + + $requestData = [ + 'orderId' => $existingOrder->getId(), + 'items' => [], + 'comment' => [ + 'comment' => 'Test Comment', + 'is_visible_on_front' => 1, + ], + ]; + $grantTotal = 0; + foreach ($existingOrder->getAllItems() as $item) { + $requestData['items'] = []; + $requestData['items'][] = [ + 'order_item_id' => $item->getItemId(), + 'qty' => $item->getQtyOrdered(), + ]; + $result = $this->_webApiCall($serviceInfo, $requestData); + $this->assertNotEmpty($result); + try { + $invoice = $this->invoiceRepository->get($result); + $grantTotal += $invoice->getGrandTotal(); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + $this->fail('Failed asserting that Invoice was created'); + } + } + $this->assertNotEquals( + $existingOrder->getGrandTotal(), + $grantTotal, + 'Failed asserting that invoice is correct.' + ); + } + + /** + * Test create invoice with Bundle product. + * + * @return void + * @magentoApiDataFixture Magento/Bundle/_files/order_item_with_bundle_and_options.php + */ + public function testInvoiceWithBundleCreate() + { + /** @var \Magento\Sales\Api\Data\OrderInterface $existingOrder*/ + $existingOrder = $this->objectManager->create(\Magento\Sales\Api\Data\OrderInterface::class) + ->loadByIncrementId('100000001'); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/order/' . $existingOrder->getId() . '/invoice', + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + ], + 'soap' => [ + 'service' => self::SERVICE_READ_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_READ_NAME . 'execute', + ], + ]; + + $requestData = [ + 'orderId' => $existingOrder->getId(), + 'items' => [], + 'comment' => [ + 'comment' => 'Test Comment', + 'is_visible_on_front' => 1, + ], + ]; + + /** @var \Magento\Sales\Api\Data\OrderItemInterface $item */ + foreach ($existingOrder->getAllItems() as $item) { + $requestData['items'][] = [ + 'order_item_id' => $item->getItemId(), + 'qty' => $item->getQtyOrdered(), + ]; + } + $result = $this->_webApiCall($serviceInfo, $requestData); + $this->assertNotEmpty($result); + $invoice = $this->invoiceRepository->get($result); + $this->assertNotEquals( + $existingOrder->getGrandTotal(), + $invoice->getGrandTotal(), + 'Failed asserting that invoice is correct.' + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php index 7aeb5c1e238d9..bc64f6ab6f23d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php @@ -10,6 +10,7 @@ use Magento\Mtf\Client\Element\SimpleElement; use Magento\Ui\Test\Block\Adminhtml\Section; use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\AbstractOptions; +use Magento\Mtf\Client\Locator; /** * Product advanced pricing section. @@ -37,6 +38,13 @@ class AdvancedPricing extends Section */ protected $doneButton = '.action-primary[data-role="action"]'; + /** + * Selector for field. + * + * @var string + */ + private $fieldByName = '//*[contains(text(),"%s")]/preceding::div[2]/ancestor::div[1]'; + /** * Fill 'Advanced price' product form on tab. * @@ -104,4 +112,15 @@ public function getTierPriceForm(SimpleElement $element = null) ['element' => $element] ); } + + /** + * Check if the field is displayed correctly. + * + * @param string $fieldName + * @return bool + */ + public function checkField($fieldName) + { + return $this->_rootElement->find(sprintf($this->fieldByName, $fieldName), Locator::SELECTOR_XPATH)->isVisible(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertProductEditPageAdvancedPricingFields.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertProductEditPageAdvancedPricingFields.php new file mode 100644 index 0000000000000..a9860ab7b7715 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertProductEditPageAdvancedPricingFields.php @@ -0,0 +1,51 @@ +open(['id' => $product->getId()]); + $catalogProductEdit->getProductForm()->openSection('advanced-pricing'); + $advancedPricing = $catalogProductEdit->getProductForm()->getSection('advanced-pricing'); + + \PHPUnit_Framework_Assert::assertTrue( + $advancedPricing->checkField($this->manufacturerFieldTitle), + '"Manufacturer\'s Suggested Retail Price" field is not correct.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return '"Manufacturer\'s Suggested Retail Price" field is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.xml b/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.xml index a5efdc3d5e917..32d86dec7a52a 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.xml +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.xml @@ -46,5 +46,9 @@ + + bundleProduct::bundle_fixed_product + + diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle.php new file mode 100644 index 0000000000000..8ca201225f842 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle.php @@ -0,0 +1,23 @@ +create(\Magento\Sales\Model\Order\Item::class); +/** @var $product \Magento\Catalog\Model\Product */ +$orderItem->setProductId($product->getId())->setQtyOrdered(1); +$orderItem->setBasePrice($product->getPrice()); +$orderItem->setPrice($product->getPrice()); +$orderItem->setRowTotal($product->getPrice()); +$orderItem->setProductType('simple'); + +/** @var \Magento\Sales\Model\Order $order */ +$order->addItem($orderItem); +$order->save(); diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle_rollback.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle_rollback.php new file mode 100644 index 0000000000000..a3b4dd410913f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle_rollback.php @@ -0,0 +1,9 @@ +assertRedirect($this->stringContains('customer/account/logoutSuccess')); } + /** + * Test that forgot password email message displays special characters correctly. + * + * @magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 0 + * @magentoConfigFixture current_store customer/password/forgot_email_template customer_password_forgot_email_template + * @magentoConfigFixture current_store customer/password/forgot_email_identity support + * @magentoConfigFixture current_store general/store_information/name Test special' characters + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testForgotPasswordEmailMessageWithSpecialCharacters() + { + $email = 'customer@example.com'; + + $this->getRequest() + ->setPostValue([ + 'email' => $email, + ]); + + $this->dispatch('customer/account/forgotPasswordPost'); + $this->assertRedirect($this->stringContains('customer/account/')); + + /** @var \Magento\TestFramework\Mail\Template\TransportBuilderMock $transportBuilder */ + $transportBuilder = $this->_objectManager->get( + \Magento\TestFramework\Mail\Template\TransportBuilderMock::class + ); + $subject = $transportBuilder->getSentMessage()->getSubject(); + $this->assertContains( + 'Test special\' characters', + $subject + ); + } + /** * @magentoDataFixture Magento/Customer/_files/customer.php */ diff --git a/dev/tests/integration/testsuite/Magento/Store/Block/SwitcherTest.php b/dev/tests/integration/testsuite/Magento/Store/Block/SwitcherTest.php new file mode 100644 index 0000000000000..d67825ea6ec8f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Store/Block/SwitcherTest.php @@ -0,0 +1,46 @@ +_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * Test that GetTargetStorePostData() method return correct store URL. + * + * @magentoDataFixture Magento/Store/_files/store.php + * @return void + */ + public function testGetTargetStorePostData() + { + $storeCode = 'test'; + /** @var \Magento\Store\Block\Switcher $block */ + $block = $this->_objectManager->create(\Magento\Store\Block\Switcher::class); + /** @var \Magento\Store\Api\StoreRepositoryInterface $storeRepository */ + $storeRepository = $this->_objectManager->create(\Magento\Store\Api\StoreRepositoryInterface::class); + $store = $storeRepository->get($storeCode); + $result = json_decode($block->getTargetStorePostData($store), true); + + $this->assertContains($storeCode, $result['action']); + } +}