예제 #1
0
 protected function setUp()
 {
     $this->markTestIncomplete();
     $this->messageManager = $this->getMockForAbstractClass('Magento\\Framework\\Message\\ManagerInterface');
     $this->config = $this->getMock('Magento\\Paypal\\Model\\Config', [], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $this->quote = $this->getMock('Magento\\Sales\\Model\\Quote', [], [], '', false);
     $this->quote->expects($this->any())->method('hasItems')->will($this->returnValue(true));
     $this->redirect = $this->getMockForAbstractClass('Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $this->customerData = $this->getMock('Magento\\Customer\\Service\\V1\\Data\\Customer', [], [], '', false);
     $this->checkout = $this->getMock('Magento\\Paypal\\Model\\Express\\Checkout', [], [], '', false);
     $this->customerSession = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
     $this->customerSession->expects($this->any())->method('getCustomerDataObject')->will($this->returnValue($this->customerData));
     $this->checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
     $this->checkoutFactory = $this->getMock('Magento\\Paypal\\Model\\Express\\Checkout\\Factory', [], [], '', false);
     $this->checkoutFactory->expects($this->any())->method('create')->will($this->returnValue($this->checkout));
     $this->checkoutSession->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $this->session = $this->getMock('Magento\\Framework\\Session\\Generic', [], [], '', false);
     $objectManager = $this->getMock('Magento\\Framework\\ObjectManager', [], [], '', false);
     $this->objectManagerCallback = function ($className) {
         if ($className == 'Magento\\Paypal\\Model\\Config') {
             return $this->config;
         }
         return $this->getMock($className, [], [], '', false);
     };
     $objectManager->expects($this->any())->method('get')->will($this->returnCallback(function ($className) {
         return call_user_func($this->objectManagerCallback, $className);
     }));
     $objectManager->expects($this->any())->method('create')->will($this->returnCallback(function ($className) {
         return call_user_func($this->objectManagerCallback, $className);
     }));
     $helper = new ObjectManagerHelper($this);
     $this->model = $helper->getObject('\\Magento\\\\Paypal\\Controller\\Express\\' . $this->name, ['messageManager' => $this->messageManager, 'response' => $this->response, 'redirect' => $this->redirect, 'request' => $this->request, 'customerSession' => $this->customerSession, 'checkoutSession' => $this->checkoutSession, 'checkoutFactory' => $this->checkoutFactory, 'paypalSession' => $this->session, 'objectManager' => $objectManager]);
 }
예제 #2
0
 protected function setUp()
 {
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['convertPrice', '__wakeup'])->getMock();
     $this->quote = $this->getMockBuilder('Magento\\Sales\\Model\\Quote')->disableOriginalConstructor()->setMethods(['getStore', '__wakeup'])->getMock();
     $this->quote->expects($this->once())->method('getStore')->will($this->returnValue($this->store));
     $checkoutSession = $this->getMockBuilder('\\Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->setMethods(['getQuote', '__wakeup'])->getMock();
     $checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($this->quote));
     $this->priceObj = $objectManager->getObject('\\Magento\\Checkout\\Block\\Shipping\\Price', ['checkoutSession' => $checkoutSession]);
 }
예제 #3
0
 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->taxConfig = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['getShippingTaxClass', 'shippingPriceIncludesTax'])->getMock();
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
     $this->quote = $this->getMockBuilder('\\Magento\\Sales\\Model\\Quote')->disableOriginalConstructor()->setMethods(['__wakeup', 'getStore'])->getMock();
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->address = $this->getMockBuilder('\\Magento\\Sales\\Model\\Quote\\Address')->disableOriginalConstructor()->setMethods(['__wakeup', 'getQuote'])->getMock();
     $this->address->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $this->commonTaxCollector = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\CommonTaxCollector', ['taxConfig' => $this->taxConfig]);
 }
예제 #4
0
 protected function setUp()
 {
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['convertPrice', '__wakeup'])->getMock();
     $this->quote = $this->getMockBuilder('Magento\\Sales\\Model\\Quote')->disableOriginalConstructor()->setMethods(['getStore', '__wakeup', 'getCustomerTaxClassId'])->getMock();
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $checkoutSession = $this->getMockBuilder('\\Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->setMethods(['getQuote', '__wakeup'])->getMock();
     $checkoutSession->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $this->taxHelper = $this->getMockBuilder('\\Magento\\Tax\\Helper\\Data')->disableOriginalConstructor()->setMethods(['getShippingPrice', 'displayShippingPriceIncludingTax', 'displayShippingBothPrices'])->getMock();
     $this->priceObj = $objectManager->getObject('\\Magento\\Tax\\Block\\Checkout\\Shipping\\Price', ['checkoutSession' => $checkoutSession, 'taxHelper' => $this->taxHelper]);
 }
예제 #5
0
 public function testInitWithNonDecimalQty()
 {
     $quoteItemMock = $this->getMock('\\Magento\\Sales\\Model\\Quote\\Item', ['getStockId', 'getIsQtyDecimal', '__wakeup'], [], '', false);
     $this->stockItemServiceMock->expects($this->once())->method('getStockItem')->will($this->returnValue($this->getStockItemDo(false)));
     $this->productMock->expects($this->once())->method('getId')->will($this->returnSelf());
     $this->productMock->expects($this->never())->method('setIsQtyDecimal');
     $this->productMock->expects($this->once())->method('setCartQty')->will($this->returnSelf());
     $this->configMock->expects($this->exactly(2))->method('getQty')->will($this->returnValue(10));
     $this->configMock->expects($this->once())->method('setQty')->will($this->returnSelf());
     $this->quoteMock->expects($this->once())->method('addProduct')->will($this->returnValue($quoteItemMock));
     $this->assertInstanceOf('Magento\\Sales\\Model\\Quote\\Item', $this->model->init($this->quoteMock, $this->productMock, $this->configMock));
 }
예제 #6
0
 /**
  * @covers \Magento\SalesRule\Model\Rule\Action\Discount\CartFixed::calculate
  */
 public function testCalculate()
 {
     $this->rule->setData(array('id' => 1, 'discount_amount' => 10.0));
     $this->address->expects($this->any())->method('getCartFixedRules')->will($this->returnValue(array()));
     $store = $this->getMock('Magento\\Store\\Model\\Store', array(), array(), '', false);
     $this->priceCurrency->expects($this->atLeastOnce())->method('convert')->will($this->returnArgument(0));
     $this->priceCurrency->expects($this->atLeastOnce())->method('round')->will($this->returnArgument(0));
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($store));
     /** validators data */
     $this->validator->expects($this->once())->method('getItemPrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemBasePrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemOriginalPrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemBaseOriginalPrice')->with($this->item)->will($this->returnValue(100));
     $this->address->expects($this->once())->method('setCartFixedRules')->with(array(1 => 0.0));
     $this->model->calculate($this->rule, $this->item, 1);
     $this->assertEquals($this->data->getAmount(), 10);
     $this->assertEquals($this->data->getBaseAmount(), 10);
     $this->assertEquals($this->data->getOriginalAmount(), 10);
     $this->assertEquals($this->data->getBaseOriginalAmount(), 100);
 }
예제 #7
0
 public function testGetSubtotalZero()
 {
     $totals = [];
     $this->quote->expects($this->once())->method('getTotals')->will($this->returnValue($totals));
     $this->assertEquals(0, $this->totalsObj->getSubtotal());
 }
예제 #8
0
 public function testGetBaseSubtotal()
 {
     $this->_quoteMock->expects($this->once())->method('__call')->with('getBaseSubtotal')->will($this->returnValue(100));
     $this->assertEquals(100, $this->_model->getBaseSubtotal());
 }
예제 #9
0
 /**
  * @dataProvider getSubtotalExclTaxDataProvider
  */
 public function testGetSubtotalExclTax($totals, $expectedValue)
 {
     $this->quote->expects($this->once())->method('getTotals')->will($this->returnValue($totals));
     $this->assertEquals($expectedValue, $this->totalsObj->getSubtotalExclTax());
 }