1
0
Fork 0
mirror of synced 2025-04-06 07:13:33 +03:00
Fix tests
This commit is contained in:
Ivan Chaplygin 2024-05-16 18:09:16 +03:00
parent 5245ef56b8
commit d03d218b18
3 changed files with 32 additions and 24 deletions

View file

@ -78,25 +78,25 @@ class DataLoyaltyRetailCrm
'responseApiMethod' => [],
'wcUserType' => 'individual',
'throwMessage' => 'User not found in the system',
'isCorpActive' => false
'isCorpActive' => 'no'
],
[
'responseApiMethod' => ['customer' => ['id' => 1]],
'wcUserType' => 'corp',
'throwMessage' => 'This user is a corporate person',
'isCorpActive' => true,
'isCorpActive' => 'yes',
],
[
'responseApiMethod' => ['customer' => ['id' => 1]],
'wcUserType' => 'corp',
'throwMessage' => null,
'isCorpActive' => false,
'isCorpActive' => 'no',
],
[
'responseApiMethod' => ['customer' => ['id' => 1]],
'wcUserType' => 'individual',
'throwMessage' => null,
'isCorpActive' => true,
'isCorpActive' => 'yes',
],
];
}
@ -241,24 +241,20 @@ class DataLoyaltyRetailCrm
public static function dataGetEmailsForPersonalCoupon()
{
$data = [
return [
[
'email' => 'test1@gmail.com'
'email' => 'test1@gmail.com',
'code' => 'loyalty' . mt_rand()
],
[
'email' => 'test2@gmail.com'
'email' => 'test2@gmail.com',
'code' => 'loyalty' . mt_rand()
],
[
'email' => 'test3@gmail.com',
'expectedCode' => false
]
];
$coupons = self::createCoupons();
$data[0]['expectedCode'] = $coupons[0]->get_code();
$data[1]['expectedCode'] = $coupons[1]->get_code();
$data[2] = [
'email' => 'test3@gmail.com',
'expectedCode' => false
];
return $data;
}
public static function dataValidUser()

View file

@ -134,11 +134,21 @@ class WC_Retailcrm_Loyalty_Test extends WC_Retailcrm_Test_Case_Helper
/**
* @dataProvider DataLoyaltyRetailCrm::dataGetEmailsForPersonalCoupon()
*/
public function testGetCouponLoyalty($email, $expectedCode)
public function testGetCouponLoyalty($email, $code)
{
if ($code) {
$coupon = new WC_Coupon();
$coupon->set_usage_limit(0);
$coupon->set_amount(100);
$coupon->set_email_restrictions($email);
$coupon->set_code($code);
$coupon->save();
}
$coupons = $this->loyalty->getCouponLoyalty($email);
if (!$coupons && $expectedCode === false) {
if (!$coupons && $code === false) {
$this->assertTrue(true);
} else {
$result = false;
@ -147,7 +157,7 @@ class WC_Retailcrm_Loyalty_Test extends WC_Retailcrm_Test_Case_Helper
$coupon = new WC_Coupon($item['code']);
$result = true;
$this->assertTrue($expectedCode === $item['code']);
$this->assertTrue($code === $item['code']);
$coupon->delete(true);
}

View file

@ -1,6 +1,6 @@
<?php
use datasets\DataLoyaltyRetailCrm;
use DataLoyaltyRetailCrm;
class WC_Retailcrm_Loyalty_Validator_Test extends WC_Retailcrm_Test_Case_Helper
{
@ -33,7 +33,9 @@ class WC_Retailcrm_Loyalty_Validator_Test extends WC_Retailcrm_Test_Case_Helper
$this->corpClient->save();
}
/** @dataProvider datasets\DataLoyaltyRetailCrm::dataCheckUser() */
/**
* @dataProvider DataLoyaltyRetailCrm::dataCheckUser()
*/
public function testCheckUser($responseApiMethod, $wcUserType, $throwMessage, $isCorpActive)
{
$this->setResponseMock();
@ -57,7 +59,7 @@ class WC_Retailcrm_Loyalty_Validator_Test extends WC_Retailcrm_Test_Case_Helper
}
}
/** @dataProvider datasets\DataLoyaltyRetailCrm::dataLoyaltyAccount() */
/** @dataProvider DataLoyaltyRetailCrm::dataLoyaltyAccount() */
public function testGetLoyaltyAccount($responseMock, $throwMessage)
{
$this->setResponseMock($responseMock);
@ -79,7 +81,7 @@ class WC_Retailcrm_Loyalty_Validator_Test extends WC_Retailcrm_Test_Case_Helper
}
}
/** @dataProvider datasets\DataLoyaltyRetailCrm::dataCheckActiveLoyalty() */
/** @dataProvider DataLoyaltyRetailCrm::dataCheckActiveLoyalty() */
public function testCheckActivateLoyalty($responseMock, $throwMessage)
{
$this->setResponseMock($responseMock);