From 6c6945da2b0acd1c794fbfce188eabb8c7bf2b50 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 24 Apr 2018 10:59:12 +0300 Subject: [PATCH] fix tests --- .../Signifyd/Block/Adminhtml/CaseInfoTest.php | 13 ++++--- .../Request/CreateCaseBuilderTest.php | 9 ++--- ..._with_customer_and_two_simple_products.php | 37 +++++++++++-------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php index 71a0d5715d1aa..7607526b1389e 100644 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php @@ -8,7 +8,6 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\View\Element\Template\Context; -use Magento\Framework\View\LayoutInterface; use Magento\Sales\Model\Order; use Magento\TestFramework\Helper\Bootstrap; @@ -25,9 +24,9 @@ class CaseInfoTest extends \PHPUnit\Framework\TestCase private $order; /** - * @var LayoutInterface + * @var \Magento\Framework\View\LayoutFactory */ - private $layout; + protected $layoutFactory; /** * @inheritdoc @@ -36,7 +35,7 @@ protected function setUp() { $this->objectManager = Bootstrap::getObjectManager(); $this->order = $this->objectManager->create(Order::class); - $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->layoutFactory = $this->objectManager->get(\Magento\Framework\View\LayoutFactory::class); } /** @@ -96,10 +95,12 @@ public function testCaseEntityExists() */ private function getBlock() { - $this->layout->addContainer('order_additional_info', 'Container'); + $layout = $this->layoutFactory->create(); + + $layout->addContainer('order_additional_info', 'Container'); /** @var CaseInfo $block */ - $block = $this->layout->addBlock(CaseInfo::class, 'order_case_info', 'order_additional_info'); + $block = $layout->addBlock(CaseInfo::class, 'order_case_info', 'order_additional_info'); $block->setAttribute('context', $this->getContext()); $block->setTemplate('Magento_Signifyd::case_info.phtml'); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php index 7e7e20c873948..e53e0c26e286a 100644 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php @@ -64,7 +64,6 @@ public function testCreateCaseBuilderWithFullSetOfData() $order->loadByIncrementId('100000001'); $orderItems = $order->getAllItems(); - $product = $orderItems[0]->getProduct(); $payment = $order->getPayment(); $billingAddress = $order->getBillingAddress(); $shippingAddress = $order->getShippingAddress(); @@ -104,16 +103,16 @@ public function testCreateCaseBuilderWithFullSetOfData() 'itemName' => $orderItems[0]->getName(), 'itemPrice' => $orderItems[0]->getPrice(), 'itemQuantity' => $orderItems[0]->getQtyOrdered(), - 'itemUrl' => $product->getProductUrl(), - 'itemWeight' => $product->getWeight() + 'itemUrl' => $orderItems[0]->getProduct()->getProductUrl(), + 'itemWeight' => $orderItems[0]->getProduct()->getWeight() ], 1 => [ 'itemId' => $orderItems[1]->getSku(), 'itemName' => $orderItems[1]->getName(), 'itemPrice' => $orderItems[1]->getPrice(), 'itemQuantity' => $orderItems[1]->getQtyOrdered(), - 'itemUrl' => $product->getProductUrl(), - 'itemWeight' => $product->getWeight() + 'itemUrl' => $orderItems[1]->getProduct()->getProductUrl(), + 'itemWeight' => $orderItems[1]->getProduct()->getWeight() ] ], 'paymentMethod' => 'PAYPAL_ACCOUNT' diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php index 069ee7012cb6e..8991825c9381e 100644 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php +++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php @@ -10,7 +10,7 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Magento\TestFramework\Helper\Bootstrap; -require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/multiple_products.php'; require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; require __DIR__ . '/store.php'; @@ -36,28 +36,33 @@ ->setCcExpMonth('01') ->setCcExpYear('21'); +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); + +$product1 = $productRepository->get('simple1'); /** @var Item $orderItem */ $orderItem1 = $objectManager->create(Item::class); -$orderItem1->setProductId($product->getId()) - ->setSku($product->getSku()) - ->setName($product->getName()) +$orderItem1->setProductId($product1->getId()) + ->setSku($product1->getSku()) + ->setName($product1->getName()) ->setQtyOrdered(1) - ->setBasePrice($product->getPrice()) - ->setPrice($product->getPrice()) - ->setRowTotal($product->getPrice()) - ->setProductType($product->getTypeId()); + ->setBasePrice($product1->getPrice()) + ->setPrice($product1->getPrice()) + ->setRowTotal($product1->getPrice()) + ->setProductType($product1->getTypeId()); +$product2 = $productRepository->get('simple2'); /** @var Item $orderItem */ $orderItem2 = $objectManager->create(Item::class); -$orderItem2->setProductId($product->getId()) - ->setSku($product->getSku()) - ->setName('Simple product') - ->setPrice(100) +$orderItem2->setProductId($product2->getId()) + ->setSku($product2->getSku()) + ->setName($product2->getName()) + ->setPrice($product2->getPrice()) ->setQtyOrdered(2) - ->setBasePrice($product->getPrice()) - ->setPrice($product->getPrice()) - ->setRowTotal($product->getPrice()) - ->setProductType($product->getTypeId()); + ->setBasePrice($product2->getPrice()) + ->setPrice($product2->getPrice()) + ->setRowTotal($product2->getPrice()) + ->setProductType($product2->getTypeId()); $orderAmount = 100; $customerEmail = $billingAddress->getEmail();