/**
  * @inheritdoc
  */
 public function setUp()
 {
     parent::setUp();
     $this->quote = $this->_objectManager->create('Magento\\Quote\\Model\\Quote');
     $this->checkoutSession = $this->_objectManager->get('Magento\\Checkout\\Model\\Session');
     $this->quote->load('test01', 'reserved_order_id');
     $this->checkoutSession->setQuoteId($this->quote->getId());
     $this->checkoutSession->setCartWasUpdated(false);
 }
 /**
  * Initialize quote and customer fixtures
  */
 public function setUp()
 {
     $this->_quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Quote\\Model\\Quote');
     $this->_quote->load('test01', 'reserved_order_id');
     $this->_quote->setIsMultiShipping('0');
     $this->customerRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\CustomerRepositoryInterface');
     $this->_customer = $this->customerRepository->getById(1);
     /** @var \Magento\Sales\Model\Order\Address $address */
     $this->_address = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Quote\\Model\\Quote\\Address');
     $this->_address->setId(1);
     $this->_address->load($this->_address->getId());
     $this->_address->setQuote($this->_quote);
 }
 /**
  * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
  */
 public function testSetMethodWithoutShippingAddress()
 {
     $this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id');
     $serviceInfo = $this->getServiceInfo();
     $requestData = ['cartId' => $this->quote->getId(), 'carrierCode' => 'flatrate', 'methodCode' => 'flatrate'];
     try {
         $this->_webApiCall($serviceInfo, $requestData);
     } catch (\SoapFault $e) {
         $message = $e->getMessage();
     } catch (\Exception $e) {
         $message = json_decode($e->getMessage())->message;
     }
     $this->assertEquals('Shipping address is not set', $message);
 }
 /**
  * @magentoApiDataFixture Magento/Customer/_files/customer.php
  * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
  */
 public function testGetListForMyCart()
 {
     $this->markTestSkipped('Will be fixed after MAGETWO-35573');
     $this->_markTestAsRestOnly();
     $this->quote->load('test_order_1', 'reserved_order_id');
     /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */
     $customerTokenService = $this->objectManager->create('Magento\\Integration\\Api\\CustomerTokenServiceInterface');
     $token = $customerTokenService->createCustomerAccessToken('*****@*****.**', 'password');
     /** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */
     $shippingMethodManagementService = $this->objectManager->create('Magento\\Quote\\Api\\ShippingMethodManagementInterface');
     $shippingMethodManagementService->set($this->quote->getId(), 'flatrate', 'flatrate');
     $serviceInfo = ['rest' => ['resourcePath' => '/V1/carts/mine/shipping-methods', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, 'token' => $token]];
     $result = $this->_webApiCall($serviceInfo, []);
     $this->assertNotEmpty($result);
     $this->assertCount(1, $result);
     $shippingMethod = $shippingMethodManagementService->get($this->quote->getId());
     $expectedData = [ShippingMethodInterface::KEY_CARRIER_CODE => $shippingMethod->getCarrierCode(), ShippingMethodInterface::KEY_METHOD_CODE => $shippingMethod->getMethodCode(), ShippingMethodInterface::KEY_CARRIER_TITLE => $shippingMethod->getCarrierTitle(), ShippingMethodInterface::KEY_METHOD_TITLE => $shippingMethod->getMethodTitle(), ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingMethod->getAmount(), ShippingMethodInterface::KEY_BASE_SHIPPING_AMOUNT => $shippingMethod->getBaseAmount(), ShippingMethodInterface::KEY_AVAILABLE => $shippingMethod->getAvailable(), ShippingMethodInterface::KEY_ERROR_MESSAGE => null, ShippingMethodInterface::KEY_PRICE_EXCL_TAX => $shippingMethod->getPriceExclTax(), ShippingMethodInterface::KEY_PRICE_INCL_TAX => $shippingMethod->getPriceInclTax()];
     $this->assertEquals($expectedData, $result[0]);
 }
 /**
  * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
  */
 public function testSetMethodWithoutShippingAddress()
 {
     $this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id');
     $serviceInfo = $this->getServiceInfo();
     $cartId = $this->quote->getId();
     /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
     $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Quote\\Model\\QuoteIdMaskFactory')->create();
     $quoteIdMask->load($cartId, 'quote_id');
     //Use masked cart Id
     $cartId = $quoteIdMask->getMaskedId();
     $requestData = ['cartId' => $cartId, 'carrierCode' => 'flatrate', 'methodCode' => 'flatrate'];
     try {
         $this->_webApiCall($serviceInfo, $requestData);
     } catch (\SoapFault $e) {
         $message = $e->getMessage();
     } catch (\Exception $e) {
         $message = json_decode($e->getMessage())->message;
     }
     $this->assertEquals('Shipping address is not set', $message);
 }