/** * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php * @magentoApiDataFixture Magento/Store/_files/website.php */ public function testAddForDifferentWebsite() { $productSku = 'simple'; $serviceInfo = ['rest' => ['resourcePath' => '/V1/products/' . $productSku . '/group-prices/1/price/10', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST], 'soap' => ['service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_NAME . 'Add']]; $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'customerGroupId' => 1, 'price' => 10]); $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Api\ProductGroupPriceManagementInterface $service */ $service = $objectManager->get('Magento\\Catalog\\Api\\ProductGroupPriceManagementInterface'); $prices = $service->getList($productSku); $this->assertCount(1, $prices); $this->assertEquals(10, $prices[0]->getValue()); $this->assertEquals(1, $prices[0]->getCustomerGroupId()); }
public function testContactDataFieldsAreUpdatedByEmail() { $this->markTestSkipped(); ///updatecontactdatafieldsbyemail called /** @var ObjectManager $objectManager */ $objectManager = ObjectManager::getInstance(); $mockFormKeyValidator = $this->getMockBuilder(FromKeyValidator::class)->disableOriginalConstructor()->getMock(); $mockFormKeyValidator->method('validate')->willReturn(true); $objectManager->addSharedInstance($mockFormKeyValidator, FromKeyValidator::class); $sessionMethods = array_merge(get_class_methods(CustomerSession::class), ['getConnectorContactId']); /** * Customer Session mock. */ $mockCustomerSession = $this->getMockBuilder(CustomerSession::class)->disableOriginalConstructor()->setMethods($sessionMethods)->getMock(); $mockCustomerSession->method('getConnectorContactId')->willReturn('dummy123'); $mockCustomerSession->method('getCustomerId')->willReturn(1); $objectManager->addSharedInstance($mockCustomerSession, CustomerSession::class); /** * Customer mock. */ $customerMethods = array_merge(get_class_methods(Customer::class)); $mockCustomer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock(); /** * Store mock. */ $storeMethods = array_merge(get_class_methods(Store::class), ['getWebsite']); $mockStore = $this->getMockBuilder(Store::class)->disableOriginalConstructor()->getMock(); /** * Helper mock. */ $mockHelper = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock(); /** * Client mock. */ $mockClient = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); //\Dotdigitalgroup\Email\Helper\Data $objectManager->addSharedInstance($mockHelper, Data::class); $mockCustomerSession->method('getCustomer')->willReturn($mockCustomer); $mockCustomer->method('getStore')->willReturn($mockStore); $mockStore->method('getWebsite')->willReturn('0'); $mockHelper->method('isEnabled')->willReturn('1'); $mockHelper->method('getWebsiteApiClient')->willReturn($mockClient); $mockClient->method('getContactById')->willReturn((object) ['id' => '111']); $mockClient->method('setApiUsername')->willReturn('93465'); $mockClient->method('getDataFields')->willReturn([]); $mockClient->method('setApipassword')->willReturn('pass'); $mockClient->method('getContactById')->willReturn((object) ['id' => '111']); $mockClient->expects($this->atLeastOnce())->method('updateContactDatafieldsByEmail')->willReturn(true); $this->getRequest()->setParam('data_fields', []); $this->dispatch('connector/customer/newsletter'); }
<?php /** * Paid invoice fixture. * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ require 'order_fixture_store.php'; /** @var \Magento\Sales\Model\Order $order */ $orderService = \Magento\TestFramework\ObjectManager::getInstance()->create('Magento\\Sales\\Model\\Service\\Order', ['order' => $order]); $invoice = $orderService->prepareInvoice(); $invoice->register(); $order->setIsInProcess(true); $transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\DB\\Transaction'); $transactionSave->addObject($invoice)->addObject($order)->save();
/** * getObjectManager * * @return ObjectManager */ private function getObjectManager() { $objectManager = ObjectManager::getInstance(); return $objectManager; }
/** * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php */ public function testGet() { $productSku = 'simple'; $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Model\ProductRepository $repository */ $repository = $objectManager->create('Magento\\Catalog\\Model\\ProductRepository'); $product = $repository->get($productSku); $image = current($product->getMediaGallery('images')); $imageId = $image['value_id']; $expected = ['label' => $image['label'], 'position' => $image['position'], 'disabled' => (bool) $image['disabled'], 'file' => $image['file'], 'types' => ['image', 'small_image', 'thumbnail']]; $serviceInfo = ['rest' => ['resourcePath' => '/V1/products/' . $productSku . '/media/' . $imageId, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET], 'soap' => ['service' => 'catalogProductAttributeMediaGalleryManagementV1', 'serviceVersion' => 'V1', 'operation' => 'catalogProductAttributeMediaGalleryManagementV1Get']]; $requestData = ['sku' => $productSku, 'imageId' => $imageId]; $data = $this->_webApiCall($serviceInfo, $requestData); $actual = (array) $data; $this->assertEquals($expected['label'], $actual['label']); $this->assertEquals($expected['position'], $actual['position']); $this->assertEquals($expected['file'], $actual['file']); $this->assertEquals($expected['types'], $actual['types']); $this->assertEquals($expected['disabled'], (bool) $actual['disabled']); }
/** * @magentoDbIsolation enabled */ public function testCanBeLoadedByQuoteId() { $storeId = 1; $dummyQuoteId = 3; $model = $this->createCampaign(1, '*****@*****.**'); $model->setData('store_id', $storeId); $model->setData('quote_id', $dummyQuoteId); $model->getResource()->save($model); /** @var Campaign $emptyModel */ $emptyModel = ObjectManager::getInstance()->create(Campaign::class); $loadedModel = $emptyModel->loadByQuoteId($dummyQuoteId, $storeId); $this->assertSame($model->getId(), $loadedModel->getId()); }
/** * @param array $fixtureProduct * * @dataProvider productCreationProvider * @magentoApiDataFixture Magento/Store/_files/fixture_store_with_catalogsearch_index.php */ public function testCreateAllStoreCode($fixtureProduct) { $response = $this->saveProduct($fixtureProduct, 'all'); $this->assertArrayHasKey(ProductInterface::SKU, $response); /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ $storeManager = \Magento\TestFramework\ObjectManager::getInstance()->get('Magento\\Store\\Model\\StoreManagerInterface'); foreach ($storeManager->getStores(true) as $store) { $code = $store->getCode(); if ($code === Store::ADMIN_CODE) { continue; } $this->assertArrayHasKey(ProductInterface::SKU, $this->getProduct($fixtureProduct[ProductInterface::SKU], $code)); } $this->deleteProduct($fixtureProduct[ProductInterface::SKU]); }
<?php /** * Not paid invoice fixture for online payment method. * * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ require 'order_paid_with_payflowpro.php'; /** @var \Magento\Sales\Model\Order $order */ $orderService = \Magento\TestFramework\ObjectManager::getInstance()->create('Magento\\Sales\\Api\\InvoiceManagementInterface'); $invoice = $orderService->prepareInvoice($order); /** To allow invoice cancelling it should be created without capturing. */ $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::NOT_CAPTURE)->register(); $order = $invoice->getOrder(); $order->setIsInProcess(true); $transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\DB\\Transaction'); $transactionSave->addObject($invoice)->addObject($order)->save();
/** * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php * @magentoAppIsolation enabled */ public function testUpdateWithAllGroups() { $productSku = 'simple'; $customerGroupId = 'all'; $qty = 2; $price = 20; $serviceInfo = ['rest' => ['resourcePath' => '/V1/products/' . $productSku . '/group-prices/' . $customerGroupId . '/tiers/' . $qty . '/price/' . $price, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST], 'soap' => ['service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_NAME . 'Add']]; $requestData = ['sku' => $productSku, 'customerGroupId' => $customerGroupId, 'qty' => $qty, 'price' => $price]; $this->_webApiCall($serviceInfo, $requestData); $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Api\ProductTierPriceManagementInterface $service */ $service = $objectManager->get('Magento\\Catalog\\Api\\ProductTierPriceManagementInterface'); $prices = $service->getList($productSku, 'all'); $this->assertCount(2, $prices); $this->assertEquals(20, (int) $prices[0]->getValue()); $this->assertEquals(2, (int) $prices[0]->getQty()); }
public function testModuleIsEnabled() { $om = ObjectManager::getInstance(); // TODO: get ready }
protected function setUp() { parent::setUp(); $this->objectManager = ObjectManager::getInstance(); }
public function testRuleWithSubtotalCondition() { //subtotal $conditionValue = '300.00'; $attribute = 'subtotal'; $this->createAbandonedCartRuleWithCondition($attribute, 'gteq', $conditionValue, self::RULE_OPERATOR_AND); $quote = $this->createQuoteWithSubtotal('500.00'); $quote1 = $this->createQuoteWithSubtotal('1000.11'); $quote2 = $this->createQuoteWithSubtotal('999.11'); /** @var Rules $ruleService */ $ruleService = ObjectManager::getInstance()->create(Rules::class); $ruleService->process($this->quoteCollection, Rules::ABANDONED, $this->currentWebsiteId); $this->assertQuoteCollectionNotContains($quote); $this->assertQuoteCollectionNotContains($quote1); $this->assertQuoteCollectionNotContains($quote2); }
protected function setUp() { parent::setUp(); $this->objectManager = ObjectManager::getInstance(); $this->subject = $this->objectManager->create($this->model); }