From 55ed06fce2b15eee767c2d577e612b6a323ae945 Mon Sep 17 00:00:00 2001 From: santiagoebizmarts Date: Tue, 21 Jan 2020 11:26:18 -0300 Subject: [PATCH] Fix test --- .../MailChimp/Model/Api/PromoRulesTest.php | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/PromoRulesTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/PromoRulesTest.php index 965116dac..11580bb57 100644 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/PromoRulesTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/PromoRulesTest.php @@ -226,6 +226,7 @@ public function testGetNewPromoRuleWithError($promoRuleData) { $mailchimpStoreId = 'a1s2d3f4g5h6j7k8l9n0'; $magentoStoreId = 1; + $date = '2020-01-21 09:00:00'; $ruleName = $promoRuleData['title']; $ruleSimpleAction = 'by_percent'; $ruleIsActive = true; @@ -235,9 +236,9 @@ public function testGetNewPromoRuleWithError($promoRuleData) ->disableOriginalConstructor() ->setMethods( array( - 'getPromoRule', '_updateSyncData', 'getHelper', - 'getMailChimpDiscountAmount', 'getMailChimpType', 'getDateHelper', - 'getMailChimpTarget', 'ruleIsNotCompatible', 'ruleHasMissingInformation' + 'getPromoRule', '_updateSyncData', 'getHelper', 'getMailChimpDiscountAmount', 'getMailChimpType', + 'getDateHelper', 'getMailChimpTarget', 'ruleIsNotCompatible', 'ruleHasMissingInformation', + 'addSyncDataError' ) ) ->getMock(); @@ -246,9 +247,8 @@ public function testGetNewPromoRuleWithError($promoRuleData) ->disableOriginalConstructor() ->setMethods( array( - 'getRuleId', 'getName', 'getDescription', - 'getFromDate', 'getToDate', 'getSimpleAction', - 'getIsActive', 'setMailchimpSyncError' + 'getRuleId', 'getName', 'getDescription', 'getFromDate', 'getToDate', 'getSimpleAction', + 'getIsActive', 'setMailchimpSyncError', 'getMailchimpSyncError' ) ) ->getMock(); @@ -258,12 +258,12 @@ public function testGetNewPromoRuleWithError($promoRuleData) ->getMock(); $mailChimpDateHelperMock = $this->getMockBuilder(Ebizmarts_MailChimp_Helper_Date::class) - ->setMethods(array('getDateMicrotime')) + ->setMethods(array('getDateMicrotime', 'formatDate')) ->disableOriginalConstructor() ->getMock(); $promoRulesApiMock - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('getHelper') ->willReturn($mailChimpHelperMock); @@ -307,6 +307,17 @@ public function testGetNewPromoRuleWithError($promoRuleData) $promoRuleMock->expects($this->once())->method('getSimpleAction')->willReturn($ruleSimpleAction); $promoRuleMock->expects($this->once())->method('getIsActive')->willReturn($ruleIsActive); $promoRuleMock->expects($this->once())->method('setMailchimpSyncError')->with($error); + $promoRuleMock->expects($this->once())->method('getMailchimpSyncError')->willReturn($error); + + $mailChimpDateHelperMock->expects($this->once()) + ->method('formatDate') + ->with(null, "Y-m-d H:i:s") + ->willReturn($date); + + $promoRulesApiMock->expects($this->once()) + ->method('addSyncDataError') + ->with($promoRuleData['id'], $promoRuleData['error'], null, false, $date); + $return = $promoRulesApiMock->getNewPromoRule(self::PROMORULE_ID, $mailchimpStoreId, $magentoStoreId);