44 $this->_helperMock = $this->createMock(\
Magento\GoogleAdwords\Helper\Data::class);
45 $this->_registryMock = $this->createMock(\
Magento\Framework\Registry::class);
46 $this->_collectionMock = $this->createMock(\
Magento\Sales\Model\
ResourceModel\Order\Collection::class);
47 $this->_eventObserverMock = $this->createMock(\
Magento\Framework\Event\Observer::class);
48 $this->_eventMock = $this->createPartialMock(\
Magento\Framework\Event::class, [
'getOrderIds']);
50 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
52 \
Magento\GoogleAdwords\Observer\SetConversionValueObserver::class,
54 'helper' => $this->_helperMock,
55 'collection' => $this->_collectionMock,
56 'registry' => $this->_registryMock
66 return [[
false,
false], [
false,
true], [
true,
false]];
77 $this->_helperMock->expects(
80 'isGoogleAdwordsActive' 82 $this->returnValue($isActive)
84 $this->_helperMock->expects($this->any())->method(
'isDynamicConversionValue')->will(
85 $this->returnCallback(
86 function () use ($isDynamic) {
92 $this->_eventMock->expects($this->never())->method(
'getOrderIds');
93 $this->assertSame($this->_model, $this->_model->execute($this->_eventObserverMock));
111 $this->_helperMock->expects($this->once())->method(
'isGoogleAdwordsActive')->will($this->returnValue(
true));
112 $this->_helperMock->expects($this->once())->method(
'isDynamicConversionValue')->will($this->returnValue(
true));
113 $this->_eventMock->expects($this->once())->method(
'getOrderIds')->will($this->returnValue($ordersIds));
114 $this->_eventObserverMock->expects(
119 $this->returnValue($this->_eventMock)
121 $this->_collectionMock->expects($this->never())->method(
'addFieldToFilter');
123 $this->assertSame($this->_model, $this->_model->execute($this->_eventObserverMock));
131 $ordersIds = [1, 2, 3];
132 $conversionValue = 0;
133 $conversionCurrency =
'USD';
134 $this->_helperMock->expects($this->once())->method(
'isGoogleAdwordsActive')->will($this->returnValue(
true));
135 $this->_helperMock->expects($this->once())->method(
'isDynamicConversionValue')->will($this->returnValue(
true));
136 $this->_helperMock->expects($this->once())->method(
'hasSendConversionValueCurrency')
137 ->will($this->returnValue(
true));
138 $this->_eventMock->expects($this->once())->method(
'getOrderIds')->will($this->returnValue($ordersIds));
139 $this->_eventObserverMock->expects(
144 $this->returnValue($this->_eventMock)
147 $orderMock = $this->createMock(\
Magento\Sales\Api\
Data\OrderInterface::class);
148 $orderMock->expects($this->once())->method(
'getOrderCurrencyCode')->willReturn($conversionCurrency);
150 $iteratorMock = new \ArrayIterator([$orderMock]);
151 $this->_collectionMock->expects($this->any())->method(
'getIterator')->will($this->returnValue($iteratorMock));
152 $this->_collectionMock->expects(
160 $this->_registryMock->expects(
175 $this->assertSame($this->_model, $this->_model->execute($this->_eventObserverMock));
testSetConversionValueWhenAdwordsActiveWithOrdersIds()
const CONVERSION_VALUE_REGISTRY_NAME
testSetConversionValueWhenAdwordsActiveWithoutOrdersIds($ordersIds)
testSetConversionValueWhenAdwordsDisabled($isActive, $isDynamic)
const CONVERSION_VALUE_CURRENCY_REGISTRY_NAME
dataProviderForDisabled()
dataProviderForOrdersIds()