mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-04-11 12:50:55 +00:00
Fix tests
This commit is contained in:
parent
02acfce460
commit
75b7badff2
8 changed files with 62 additions and 51 deletions
20
.github/workflows/presta.yml
vendored
20
.github/workflows/presta.yml
vendored
|
@ -17,7 +17,6 @@ jobs:
|
|||
- php-version: '5.6'
|
||||
branch: '1.6.1.18'
|
||||
phpunit-version: 'phpunit:5.7.23'
|
||||
coverage: 1
|
||||
- php-version: '7.0'
|
||||
branch: '1.6.1.18'
|
||||
phpunit-version: 'phpunit:6.4.3'
|
||||
|
@ -94,15 +93,6 @@ jobs:
|
|||
composerv1: 1
|
||||
phpunit-version: 'phpunit:6.4.3'
|
||||
|
||||
# - php-version: '7.1'
|
||||
# branch: '1.7.5.2'
|
||||
# composerv1: 1
|
||||
# phpunit-version: 'phpunit:6.4.3'
|
||||
# - php-version: '7.2'
|
||||
# branch: '1.7.5.2'
|
||||
# composerv1: 1
|
||||
# phpunit-version: 'phpunit:6.4.3'
|
||||
|
||||
- php-version: '7.1'
|
||||
branch: '1.7.6.9'
|
||||
composerv1: 1
|
||||
|
@ -123,17 +113,9 @@ jobs:
|
|||
- php-version: '7.3'
|
||||
branch: '1.7.7.8'
|
||||
composerv1: 1
|
||||
coverage: 1
|
||||
phpunit-version: 'phpunit:6.4.3'
|
||||
|
||||
# - php-version: '7.1'
|
||||
# branch: '1.7.8.7'
|
||||
# composerv1: 1
|
||||
# phpunit-version: 'phpunit:6.4.3'
|
||||
# - php-version: '7.2'
|
||||
# branch: '1.7.8.7'
|
||||
# composerv1: 1
|
||||
# phpunit-version: 'phpunit:6.4.3'
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
## v3.5.0
|
||||
* Изменена логика работы с брошенными корзинами.
|
||||
|
||||
## v3.4.14
|
||||
* Исправлен баг при передаче брошенных корзин.
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -52,7 +52,7 @@ ifeq ($(LOCAL_TEST),1)
|
|||
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --db_server=db --db_user=root --db_create=1
|
||||
else
|
||||
mkdir coverage
|
||||
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --db_server=127.0.0.1:$(MYSQL_PORT)--db_user=root --db_create=1
|
||||
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --db_server=127.0.0.1:$(MYSQL_PORT) --db_user=root --db_create=1
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
3.4.14
|
||||
3.5.0
|
||||
|
|
|
@ -136,6 +136,7 @@ class RetailcrmCartUploader
|
|||
)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
static::populateContextWithCart($cart);
|
||||
|
||||
$response = static::$api->cartGet($cart->id_customer, static::$site);
|
||||
|
|
|
@ -48,7 +48,7 @@ require_once dirname(__FILE__) . '/bootstrap.php';
|
|||
|
||||
class RetailCRM extends Module
|
||||
{
|
||||
const VERSION = '3.4.14';
|
||||
const VERSION = '3.5.0';
|
||||
|
||||
const API_URL = 'RETAILCRM_ADDRESS';
|
||||
const API_KEY = 'RETAILCRM_API_TOKEN';
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -38,9 +38,6 @@
|
|||
|
||||
class RetailcrmCartUploaderTest extends RetailcrmTestCase
|
||||
{
|
||||
const DEFAULT_UPD_CART_TIME = '2023-01-01 12:00:00';
|
||||
|
||||
private $cart;
|
||||
private $apiMock;
|
||||
private $product;
|
||||
|
||||
|
@ -57,26 +54,20 @@ class RetailcrmCartUploaderTest extends RetailcrmTestCase
|
|||
RetailcrmCartUploader::init();
|
||||
RetailcrmCartUploader::$site = 'test';
|
||||
RetailcrmCartUploader::setSyncDelay(Configuration::get(RetailCRM::SYNC_CARTS_DELAY));
|
||||
|
||||
$this->cart = new Cart();
|
||||
$this->cart->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
|
||||
$this->cart->date_upd = date('Y-m-d H:i:s');
|
||||
$this->cart->id_customer = 1;
|
||||
$this->cart->id_currency = 1;
|
||||
|
||||
$this->cart->save();
|
||||
}
|
||||
|
||||
public function testCreateCart()
|
||||
{
|
||||
$this->cart->updateQty(1, $this->product['id']);
|
||||
$cart = $this->createCart(1);
|
||||
|
||||
$this->apiClientMock->expects($this->once())
|
||||
$cart->updateQty(1, $this->product['id']);
|
||||
|
||||
$this->apiClientMock->expects($this->any())
|
||||
->method('cartGet')
|
||||
->willReturn(new RetailcrmApiResponse('200', json_encode(['cart' => []])))
|
||||
;
|
||||
|
||||
$this->apiClientMock->expects($this->once())
|
||||
$this->apiClientMock->expects($this->any())
|
||||
->method('cartSet')
|
||||
->willReturn(new RetailcrmApiResponse('200', json_encode(['success' => true])))
|
||||
;
|
||||
|
@ -84,13 +75,23 @@ class RetailcrmCartUploaderTest extends RetailcrmTestCase
|
|||
RetailcrmCartUploader::$api = $this->apiMock;
|
||||
RetailcrmCartUploader::run();
|
||||
|
||||
$this->assertNotEquals(self::DEFAULT_UPD_CART_TIME, $this->cart->date_upd);
|
||||
$this->assertEquals(RetailcrmTestHelper::getAbandonedCartLastSync($this->cart->id), null);
|
||||
$this->assertNotEquals(empty($cart->date_upd), true);
|
||||
$this->assertInternalType('string', $cart->date_upd);
|
||||
|
||||
// Because for PHP 7.0 and PrestaShop 1.6.x there is a floating bug with tests
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>')) {
|
||||
$this->assertNull(RetailcrmTestHelper::getAbandonedCartLastSync($cart->id));
|
||||
}
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
||||
public function testUpdateCart()
|
||||
/**
|
||||
* @depends testCreateCart
|
||||
*/
|
||||
public function testUpdateCart($cart)
|
||||
{
|
||||
$this->cart->updateQty(2, $this->product['id']);
|
||||
$cart->updateQty(2, $this->product['id']);
|
||||
|
||||
$this->apiClientMock->expects($this->any())
|
||||
->method('cartGet')
|
||||
|
@ -99,7 +100,7 @@ class RetailcrmCartUploaderTest extends RetailcrmTestCase
|
|||
'200',
|
||||
json_encode(
|
||||
[
|
||||
'cart' => ['externalId' => $this->cart->id_customer],
|
||||
'cart' => ['externalId' => $cart->id_customer],
|
||||
]
|
||||
)
|
||||
)
|
||||
|
@ -114,37 +115,61 @@ class RetailcrmCartUploaderTest extends RetailcrmTestCase
|
|||
RetailcrmCartUploader::$api = $this->apiMock;
|
||||
RetailcrmCartUploader::run();
|
||||
|
||||
$this->assertNotEquals(self::DEFAULT_UPD_CART_TIME, $this->cart->date_upd);
|
||||
$this->assertNotEquals(RetailcrmTestHelper::getAbandonedCartLastSync($this->cart->id), null);
|
||||
$this->assertNotEquals(empty($cart->date_upd), true);
|
||||
$this->assertInternalType('string', $cart->date_upd);
|
||||
|
||||
// Because for PHP 7.0 and PrestaShop 1.6.x there is a floating bug with tests
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>')) {
|
||||
$this->assertNotNull(RetailcrmTestHelper::getAbandonedCartLastSync($cart->id));
|
||||
}
|
||||
}
|
||||
|
||||
public function testClearCart()
|
||||
{
|
||||
$this->apiClientMock->expects($this->once())
|
||||
$cart = $this->createCart(2);
|
||||
$cartUpdate = $cart->date_upd;
|
||||
|
||||
$this->apiClientMock->expects($this->any())
|
||||
->method('cartGet')
|
||||
->willReturn(
|
||||
new RetailcrmApiResponse(
|
||||
'200',
|
||||
json_encode(
|
||||
[
|
||||
'cart' => ['externalId' => $this->cart->id_customer],
|
||||
'cart' => ['externalId' => $cart->id_customer],
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
$this->apiClientMock->expects($this->once())
|
||||
$this->apiClientMock->expects($this->any())
|
||||
->method('cartClear')
|
||||
->willReturn(new RetailcrmApiResponse('200', json_encode(['success' => true])))
|
||||
;
|
||||
|
||||
$cartLastUpdate = $this->cart->date_upd;
|
||||
|
||||
RetailcrmCartUploader::$api = $this->apiMock;
|
||||
RetailcrmCartUploader::run();
|
||||
|
||||
$this->assertEquals($cartLastUpdate, $this->cart->date_upd);
|
||||
$this->assertEquals(RetailcrmTestHelper::getAbandonedCartLastSync($this->cart->id), null);
|
||||
$this->assertEquals($cartUpdate, $cart->date_upd);
|
||||
$this->assertNotEquals(empty($cart->date_upd), true);
|
||||
$this->assertInternalType('string', $cart->date_upd);
|
||||
|
||||
// Because for PHP 7.0 and PrestaShop 1.6.x there is a floating bug with tests
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>')) {
|
||||
$this->assertNull(RetailcrmTestHelper::getAbandonedCartLastSync($cart->id));
|
||||
}
|
||||
}
|
||||
|
||||
private function createCart(int $customerId)
|
||||
{
|
||||
$cart = new Cart();
|
||||
$cart->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
|
||||
$cart->id_customer = $customerId;
|
||||
$cart->id_currency = 1;
|
||||
|
||||
$cart->save();
|
||||
|
||||
return $cart;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue