Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seruymt committed Apr 24, 2018
1 parent 884e138 commit 6c6945d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -25,9 +24,9 @@ class CaseInfoTest extends \PHPUnit\Framework\TestCase
private $order;

/**
* @var LayoutInterface
* @var \Magento\Framework\View\LayoutFactory
*/
private $layout;
protected $layoutFactory;

/**
* @inheritdoc
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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();
Expand Down

0 comments on commit 6c6945d

Please sign in to comment.