forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into PR_08062017
- Loading branch information
Showing
9 changed files
with
349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderInvoiceCreateTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...nal/tests/app/Magento/Msrp/Test/Constraint/AssertProductEditPageAdvancedPricingFields.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
dev/tests/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
9 changes: 9 additions & 0 deletions
9
...ts/integration/testsuite/Magento/Bundle/_files/order_items_simple_and_bundle_rollback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
dev/tests/integration/testsuite/Magento/Store/Block/SwitcherTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | ||
} | ||
} |