Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into PR_08062017
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Vilchynskyi committed Jun 12, 2017
2 parents 0ed852c + 519a65d commit 8022747
Show file tree
Hide file tree
Showing 9 changed files with 349 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
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.
*/
namespace Magento\Bundle\Api;

/**
* API test for creation of Invoice for order with bundle product.
*/
class OrderInvoiceCreateTest extends \Magento\TestFramework\TestCase\WebapiAbstract
{
const SERVICE_READ_NAME = 'salesInvoiceOrderV1';
const SERVICE_VERSION = 'V1';

/**
* @var \Magento\Framework\ObjectManagerInterface
*/
private $objectManager;

/**
* @var \Magento\Sales\Api\InvoiceRepositoryInterface
*/
private $invoiceRepository;

/**
* Set up.
*
* @return void
*/
protected function setUp()
{
$this->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.'
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Msrp\Test\Constraint;

use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
use Magento\Mtf\Constraint\AbstractConstraint;
use Magento\Mtf\Fixture\FixtureInterface;

/**
* Check "Manufacturer's Suggested Retail Price" field on "Advanced pricing" page.
*/
class AssertProductEditPageAdvancedPricingFields extends AbstractConstraint
{
/**
* Title of "Manufacturer's Suggested Retail Price" field.
*
* @var string
*/
private $manufacturerFieldTitle = 'Manufacturer\'s Suggested Retail Price';

/**
* @param CatalogProductEdit $catalogProductEdit
* @param FixtureInterface $product
* @return void
*/
public function processAssert(CatalogProductEdit $catalogProductEdit, FixtureInterface $product)
{
$catalogProductEdit->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.';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@
<constraint name="Magento\Msrp\Test\Constraint\AssertMapOnProductView" />
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpInShoppingCart" />
</variation>
<variation name="ApplyMapTestVariation6" summary="[Catalog] MSRP field is not displayed for bundle products with fixed price" ticketId="MAGETWO-63054">
<data name="product" xsi:type="string">bundleProduct::bundle_fixed_product</data>
<constraint name="Magento\Msrp\Test\Constraint\AssertProductEditPageAdvancedPricingFields" />
</variation>
</testCase>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

require __DIR__ . '/order_item_with_bundle_and_options.php';
require __DIR__ . '/../../../Magento/Catalog/_files/category_product.php';

$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();

/** @var \Magento\Sales\Model\Order\Item $orderItem */
$orderItem = $objectManager->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();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

require __DIR__ . '/../../../Magento/Catalog/_files/category_product_rollback.php';
require __DIR__ . '/product_with_multiple_options_rollback.php';
require __DIR__ . '/../../../Magento/Sales/_files/default_rollback.php';
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,38 @@ public function testLogoutAction()
$this->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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Store\Block;

/**
* Integration tests for \Magento\Store\Block\Switcher block.
*/
class SwitcherTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\TestFramework\ObjectManager
*/
private $_objectManager;

/**
* Set up.
*
* @return void
*/
protected function setUp()
{
$this->_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']);
}
}

0 comments on commit 8022747

Please sign in to comment.