From fc7c004988a5f4e720c8af11cbf1092360481116 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 19 Feb 2020 18:17:23 +0300 Subject: [PATCH 1/7] update matrix, remove deprecated --- .travis.yml | 106 ++++++++++++++++++++++++++++++++++++++++------------ Makefile | 2 +- 2 files changed, 83 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 29d961b..ae6f6a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,7 @@ +os: linux language: php - dist: trusty -sudo: false - if: tag IS blank env: @@ -38,29 +36,89 @@ after_success: jobs: include: - php: 7.0 - env: - - TEST_SUITE=2.3 - - OPENCART=2.3 - - php: 7.1 - env: - - TEST_SUITE=2.3 - - OPENCART=2.3 + env: TEST_SUITE=2.3 OPENCART=2.3.0.0 - php: 7.0 - env: - - TEST_SUITE=3.0 - - OPENCART=3.0 + env: TEST_SUITE=2.3 OPENCART=2.3.0.1 + - php: 7.0 + env: TEST_SUITE=2.3 OPENCART=2.3.0.2 - php: 7.1 - env: - - TEST_SUITE=3.0 - - OPENCART=3.0 + env: TEST_SUITE=2.3 OPENCART=2.3.0.0 + - php: 7.1 + env: TEST_SUITE=2.3 OPENCART=2.3.0.1 + - php: 7.1 + env: TEST_SUITE=2.3 OPENCART=2.3.0.2 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.0.0 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.0.2 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.1.0 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.1.1 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.1.2 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.2.0 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.3.0 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.3.1 + - php: 7.0 + env: TEST_SUITE=3.0 OPENCART=3.0.3.2 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.0.0 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.0.2 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.1.0 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.1.1 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.1.2 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.2.0 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.3.0 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.3.1 + - php: 7.1 + env: TEST_SUITE=3.0 OPENCART=3.0.3.2 - php: 7.2 - env: - - TEST_SUITE=3.0 - - OPENCART=3.0 + env: TEST_SUITE=3.0 OPENCART=3.0.0.0 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.0.2 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.1.0 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.1.1 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.1.2 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.2.0 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.3.0 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.3.1 + - php: 7.2 + env: TEST_SUITE=3.0 OPENCART=3.0.3.2 - php: 7.3 - env: - - TEST_SUITE=3.0 - - OPENCART=3.0 + env: TEST_SUITE=3.0 OPENCART=3.0.0.0 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.0.2 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.1.0 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.1.1 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.1.2 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.2.0 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.3.0 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.3.1 + - php: 7.3 + env: TEST_SUITE=3.0 OPENCART=3.0.3.2 - stage: deploy before_script: skip script: make build_archive @@ -73,8 +131,8 @@ jobs: - git tag $TRAVIS_TAG deploy: provider: releases - api_key: $GITHUB_OAUTH_TOKEN - skip_cleanup: true + token: $GITHUB_OAUTH_TOKEN + cleanup: false file: $ARCHIVE_NAME on: condition: "$LAST_TAG != $CURRENT_VERSION" diff --git a/Makefile b/Makefile index d696803..a495dad 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ before_script: # Change MySQL root password echo "USE mysql;\nUPDATE user SET password=PASSWORD('root') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root composer require --dev beyondit/opencart-test-suite ~$(TEST_SUITE) - composer require --dev opencart/opencart ~$(OPENCART) + composer require --dev opencart/opencart $(OPENCART) composer setup bin/robo --load-from tests/RoboFile.php project:deploy (php -S localhost:8000 -t www &) 2> /dev/null > /dev/null From 8c8ee17c3da5fe57d5df6880d339a6abae758032 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 19 Feb 2020 21:22:53 +0300 Subject: [PATCH 2/7] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f636108..a0be130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## v.3.3.7 -* Изменена конфигурация travis-ci для сборки и развертывания +* Изменена конфигурация travis-ci для сборки ## v.3.3.6 * Небольшие фиксы From 440e16b50bd9268c40dc4aa9aeb806179422afdc Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Wed, 19 Feb 2020 17:43:55 +0300 Subject: [PATCH 3/7] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f717a61..7ea509f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://img.shields.io/travis/retailcrm/opencart-module/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/opencart-module) +[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/opencart-module/master.svg?style=flat-square)](https://codecov.io/gh/retailcrm/opencart-module) [![GitHub release](https://img.shields.io/github/release/retailcrm/opencart-module.svg?style=flat-square)](https://github.com/retailcrm/opencart-module/releases) [![PHP version](https://img.shields.io/badge/PHP->=5.4-blue.svg?style=flat-square)](https://php.net/) From a48ef3e1eaf1154f3e53b0847bc15e2c76ca138f Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 19 Feb 2020 21:50:16 +0300 Subject: [PATCH 4/7] 'bugfixes' --- tests/admin/ControllerRetailcrmAdminTest.php | 2 +- tests/admin/ModelRetailcrmCustomerAdminTest.php | 2 +- tests/admin/ModelRetailcrmEventAdminTest.php | 2 +- tests/admin/ModelRetailcrmOrderAdminTest.php | 2 +- tests/admin/ModelRetailcrmPricesAdminTest.php | 2 +- tests/catalog/ControllerRetailcrmApiCatalogTest.php | 2 +- tests/catalog/ModelRetailcrmCustomerCatalogTest.php | 2 +- tests/catalog/ModelRetailcrmOrderCatalogTest.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/admin/ControllerRetailcrmAdminTest.php b/tests/admin/ControllerRetailcrmAdminTest.php index 7287b2e..ad382c1 100644 --- a/tests/admin/ControllerRetailcrmAdminTest.php +++ b/tests/admin/ControllerRetailcrmAdminTest.php @@ -1,6 +1,6 @@ Date: Thu, 20 Feb 2020 10:26:40 +0300 Subject: [PATCH 5/7] fix for OC 3 --- tests/RoboFile.php | 13 ++++++++++--- tests/opencart_sample_data.sql | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/RoboFile.php b/tests/RoboFile.php index e7d36d4..bdeab3a 100644 --- a/tests/RoboFile.php +++ b/tests/RoboFile.php @@ -72,7 +72,14 @@ class RoboFile extends \Robo\Tasks public function opencartSetup() { - $this->taskDeleteDir('www')->run(); + $startUp = getenv('TEST_SUITE') === '2.3' + ? 'catalog/controller/startup/test_startup.php' + : 'admin/controller/startup/test_startup.php'; + $startUpTo = getenv('TEST_SUITE') === '2.3' + ? 'catalog/controller/startup/test_startup.php' + : 'admin/controller/startup/test_startup.php'; + + $this->taskDeleteDir($this->root_dir . 'www')->run(); $this->taskFileSystemStack() ->mirror( $this->root_dir . 'vendor/opencart/opencart/upload', @@ -83,8 +90,8 @@ class RoboFile extends \Robo\Tasks $this->root_dir . 'www/system/config/test-config.php' ) ->copy( - $this->root_dir . 'vendor/beyondit/opencart-test-suite/src/upload/catalog/controller/startup/test_startup.php', - $this->root_dir . 'www/catalog/controller/startup/test_startup.php' + $this->root_dir . 'vendor/beyondit/opencart-test-suite/src/upload/' . $startUp, + $this->root_dir . 'www/' . $startUpTo ) ->chmod($this->root_dir . 'www', 0777, 0000, true) ->run(); diff --git a/tests/opencart_sample_data.sql b/tests/opencart_sample_data.sql index 3e468f0..7e872ef 100644 --- a/tests/opencart_sample_data.sql +++ b/tests/opencart_sample_data.sql @@ -1,5 +1,5 @@ TRUNCATE TABLE `oc_customer`; -INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `language_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `password`, `salt`, `cart`, `wishlist`, `newsletter`, `address_id`, `custom_field`, `ip`, `status`, `approved`, `safe`, `token`, `code`, `date_added`) VALUES ('1', '1', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', 'ed3798da75d6cdd695e99e87a60d587a10aa95ff', '51TalnrgH', '', '', '0', '1', '', '172.21.0.1', '1', '1', '0', '', '', '2018-06-07 13:50:08'); +INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `language_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `password`, `salt`, `cart`, `wishlist`, `newsletter`, `address_id`, `custom_field`, `ip`, `status`, `safe`, `token`, `code`, `date_added`) VALUES ('1', '1', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', 'ed3798da75d6cdd695e99e87a60d587a10aa95ff', '51TalnrgH', '', '', '0', '1', '', '172.21.0.1', '1', '0', '', '', '2018-06-07 13:50:08'); TRUNCATE TABLE `oc_customer_activity`; TRUNCATE TABLE `oc_customer_group`; From b921bc8c37faf71ed9da869c3a29c82cbaacf87b Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Thu, 20 Feb 2020 11:43:04 +0300 Subject: [PATCH 6/7] fix for OC 3 --- tests/opencart_sample_data.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/opencart_sample_data.sql b/tests/opencart_sample_data.sql index 7e872ef..598d7b4 100644 --- a/tests/opencart_sample_data.sql +++ b/tests/opencart_sample_data.sql @@ -27,7 +27,6 @@ TRUNCATE TABLE `oc_order`; INSERT INTO `oc_order` (`order_id`, `invoice_no`, `invoice_prefix`, `store_id`, `store_name`, `store_url`, `customer_id`, `customer_group_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `custom_field`, `payment_firstname`, `payment_lastname`, `payment_company`, `payment_address_1`, `payment_address_2`, `payment_city`, `payment_postcode`, `payment_country`, `payment_country_id`, `payment_zone`, `payment_zone_id`, `payment_address_format`, `payment_custom_field`, `payment_method`, `payment_code`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address_1`, `shipping_address_2`, `shipping_city`, `shipping_postcode`, `shipping_country`, `shipping_country_id`, `shipping_zone`, `shipping_zone_id`, `shipping_address_format`, `shipping_custom_field`, `shipping_method`, `shipping_code`, `comment`, `total`, `order_status_id`, `affiliate_id`, `commission`, `marketing_id`, `tracking`, `language_id`, `currency_id`, `currency_code`, `currency_value`, `ip`, `forwarded_ip`, `user_agent`, `accept_language`, `date_added`, `date_modified`) VALUES ('1', '0', 'INV-2016-00', '0', 'Opencart', 'http://localhost:8000/', '1', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', '', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Cash on delivery', 'cod', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Flat Rate', 'flat.flat', 'test comment', '106.0000', '1', '0', '0.0000', '0', '', '1', '1', 'USD', '1.00000000', '172.21.0.1', '', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', '2018-06-07 13:51:10', '2018-06-07 13:51:23'); INSERT INTO `oc_order` (`order_id`, `invoice_no`, `invoice_prefix`, `store_id`, `store_name`, `store_url`, `customer_id`, `customer_group_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `custom_field`, `payment_firstname`, `payment_lastname`, `payment_company`, `payment_address_1`, `payment_address_2`, `payment_city`, `payment_postcode`, `payment_country`, `payment_country_id`, `payment_zone`, `payment_zone_id`, `payment_address_format`, `payment_custom_field`, `payment_method`, `payment_code`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address_1`, `shipping_address_2`, `shipping_city`, `shipping_postcode`, `shipping_country`, `shipping_country_id`, `shipping_zone`, `shipping_zone_id`, `shipping_address_format`, `shipping_custom_field`, `shipping_method`, `shipping_code`, `comment`, `total`, `order_status_id`, `affiliate_id`, `commission`, `marketing_id`, `tracking`, `language_id`, `currency_id`, `currency_code`, `currency_value`, `ip`, `forwarded_ip`, `user_agent`, `accept_language`, `date_added`, `date_modified`) VALUES ('2', '0', 'INV-2016-00', '0', 'Opencart', 'http://localhost:8000/', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', '[]', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Cash on delivery', 'cod', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Flat Rate', 'flat.flat', 'test comment', '85.0000', '1', '0', '0.0000', '0', '', '1', '1', 'USD', '1.00000000', '172.21.0.1', '', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', '2018-06-07 13:53:50', '2018-06-07 13:54:00'); -TRUNCATE TABLE `oc_order_custom_field`; TRUNCATE TABLE `oc_order_history`; INSERT INTO `oc_order_history` (`order_history_id`, `order_id`, `order_status_id`, `notify`, `comment`, `date_added`) VALUES ('19', '2', '1', '0', '', '2018-06-07 13:54:00'); INSERT INTO `oc_order_history` (`order_history_id`, `order_id`, `order_status_id`, `notify`, `comment`, `date_added`) VALUES ('18', '1', '1', '0', '', '2018-06-07 13:51:23'); From 14e6584abf9f8a2471a985be1eae4f96fee2af47 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Thu, 20 Feb 2020 15:26:18 +0300 Subject: [PATCH 7/7] update for OC 3 --- tests/.env-dist => .env-dist | 0 .gitignore | 2 +- .travis.yml | 2 +- Makefile | 2 +- phpunit.xml.dist | 2 +- .../controller/extension/module/retailcrm.php | 1 - tests/RoboFile.php | 16 ++++-- tests/admin/ControllerRetailcrmAdminTest.php | 8 ++- tests/admin/ModelRetailcrmEventAdminTest.php | 7 ++- .../ControllerRetailcrmApiCatalogTest.php | 6 +- tests/opencart_sample_data.sql | 2 +- tests/opencart_sample_data_3.sql | 55 +++++++++++++++++++ 12 files changed, 90 insertions(+), 13 deletions(-) rename tests/.env-dist => .env-dist (100%) create mode 100644 tests/opencart_sample_data_3.sql diff --git a/tests/.env-dist b/.env-dist similarity index 100% rename from tests/.env-dist rename to .env-dist diff --git a/.gitignore b/.gitignore index 2086c68..c534094 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ /vendor /www /bin -tests/.env +.env diff --git a/.travis.yml b/.travis.yml index ae6f6a6..177b463 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ env: - OC_USERNAME=admin - OC_PASSWORD=admin - OC_EMAIL=test@test.com - - SERVER_PORT=8000 + - SERVER_PORT=80 - SERVER_URL=http://localhost stages: diff --git a/Makefile b/Makefile index a495dad..5066fb9 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ before_script: composer require --dev opencart/opencart $(OPENCART) composer setup bin/robo --load-from tests/RoboFile.php project:deploy - (php -S localhost:8000 -t www &) 2> /dev/null > /dev/null + (php -S localhost:80 -t www &) 2> /dev/null > /dev/null sleep 2 coverage: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 531d08b..367879c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,7 +19,7 @@ - + diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index a229c4f..2438992 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -469,7 +469,6 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->response->setOutput( $this->load->view('extension/module/retailcrm', $_data) ); - } /** diff --git a/tests/RoboFile.php b/tests/RoboFile.php index bdeab3a..7313c66 100644 --- a/tests/RoboFile.php +++ b/tests/RoboFile.php @@ -1,9 +1,6 @@ chmod($this->root_dir . 'www', 0777, 0000, true) ->run(); + if (getenv('TEST_SUITE') === '3.0') { + $this->taskFileSystemStack()->copy( + $this->root_dir . 'vendor/beyondit/opencart-test-suite/src/upload/system/library/session/test.php', + $this->root_dir . 'www/system/library/session/test.php' + )->run(); + } + // Create new database, drop if exists already try { $conn = new PDO("mysql:host=".$this->opencart_config['db_hostname'], $this->opencart_config['db_username'], $this->opencart_config['db_password']); @@ -175,7 +179,11 @@ class RoboFile extends \Robo\Tasks private function restoreSampleData($conn) { - $sql = file_get_contents($this->root_dir . 'tests/opencart_sample_data.sql'); + if (getenv('TEST_SUITE') === '2.3') { + $sql = file_get_contents($this->root_dir . 'tests/opencart_sample_data.sql'); + } else { + $sql = file_get_contents($this->root_dir . 'tests/opencart_sample_data_3.sql'); + } $conn->exec("USE " . $this->opencart_config['db_database']); diff --git a/tests/admin/ControllerRetailcrmAdminTest.php b/tests/admin/ControllerRetailcrmAdminTest.php index ad382c1..365b9fc 100644 --- a/tests/admin/ControllerRetailcrmAdminTest.php +++ b/tests/admin/ControllerRetailcrmAdminTest.php @@ -8,10 +8,12 @@ class ControllerRetailcrmAdminTest extends TestCase public function setUp() { + parent::setUp(); + $query = $this->db->query("SELECT permission from ".DB_PREFIX."user_group WHERE name = 'Administrator'"); $permissions = json_decode($query->row['permission'],true); - if (!in_array('extension/module/retailcrm',$permissions['access'])) { + if (!in_array('extension/module/retailcrm', $permissions['access'])) { $permissions['access'][] = 'extension/module/retailcrm'; $this->db->query("UPDATE ".DB_PREFIX."user_group SET permission='".$this->db->escape(json_encode($permissions))."' WHERE name = 'Administrator'"); } @@ -56,4 +58,8 @@ class ControllerRetailcrmAdminTest extends TestCase $this->assertRegExp('/Connection settings/', $response->getOutput()); } + + public function tearDown() + { + } } diff --git a/tests/admin/ModelRetailcrmEventAdminTest.php b/tests/admin/ModelRetailcrmEventAdminTest.php index 02bf663..4f65c18 100644 --- a/tests/admin/ModelRetailcrmEventAdminTest.php +++ b/tests/admin/ModelRetailcrmEventAdminTest.php @@ -10,7 +10,12 @@ class ModelRetailcrmEventAdminTest extends TestCase { parent::setUp(); - $eventModel = $this->loadModel('extension/event'); + if (getenv('TEST_SUITE') === '3.0') { + $eventModel = $this->loadModel('setting/event'); + } else { + $eventModel = $this->loadModel('extension/event'); + } + $eventModel->addEvent(self::CODE, 'test', 'test'); } diff --git a/tests/catalog/ControllerRetailcrmApiCatalogTest.php b/tests/catalog/ControllerRetailcrmApiCatalogTest.php index 1db1df7..ad2d520 100644 --- a/tests/catalog/ControllerRetailcrmApiCatalogTest.php +++ b/tests/catalog/ControllerRetailcrmApiCatalogTest.php @@ -8,6 +8,7 @@ class ControllerRetailcrmApiCatalogTest extends TestCase private $retailcrm; const ORDER_ID = 1; + const USERNAME = 'Default'; public function setUp() { @@ -25,8 +26,9 @@ class ControllerRetailcrmApiCatalogTest extends TestCase ) ); - if (isset($this->request->get['key'])) { + if (isset($this->request->get['key']) && isset($this->request->get['username'])) { unset($this->request->get['key']); + unset($this->request->get['username']); } } @@ -38,6 +40,7 @@ class ControllerRetailcrmApiCatalogTest extends TestCase $this->assertEquals('Not found api key', $data->error); $this->request->get['key'] = $this->apiKey; + $this->request->get['username'] = static::USERNAME; $response = $this->dispatchAction('api/retailcrm/getDeliveryTypes'); $data = json_decode($response->getOutput()); @@ -52,6 +55,7 @@ class ControllerRetailcrmApiCatalogTest extends TestCase $this->assertEquals('Not found api key', $data->error); $this->request->get['key'] = $this->apiKey; + $this->request->get['username'] = static::USERNAME; $response = $this->dispatchAction('api/retailcrm/addOrderHistory'); $data = json_decode($response->getOutput()); diff --git a/tests/opencart_sample_data.sql b/tests/opencart_sample_data.sql index 598d7b4..1954565 100644 --- a/tests/opencart_sample_data.sql +++ b/tests/opencart_sample_data.sql @@ -1,5 +1,5 @@ TRUNCATE TABLE `oc_customer`; -INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `language_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `password`, `salt`, `cart`, `wishlist`, `newsletter`, `address_id`, `custom_field`, `ip`, `status`, `safe`, `token`, `code`, `date_added`) VALUES ('1', '1', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', 'ed3798da75d6cdd695e99e87a60d587a10aa95ff', '51TalnrgH', '', '', '0', '1', '', '172.21.0.1', '1', '0', '', '', '2018-06-07 13:50:08'); +INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `language_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `password`, `salt`, `cart`, `wishlist`, `newsletter`, `address_id`, `custom_field`, `ip`, `status`, `approved`, `safe`, `token`, `code`, `date_added`) VALUES ('1', '1', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', 'ed3798da75d6cdd695e99e87a60d587a10aa95ff', '51TalnrgH', '', '', '0', '1', '', '172.21.0.1', '1', '1', '0', '', '', '2018-06-07 13:50:08'); TRUNCATE TABLE `oc_customer_activity`; TRUNCATE TABLE `oc_customer_group`; diff --git a/tests/opencart_sample_data_3.sql b/tests/opencart_sample_data_3.sql new file mode 100644 index 0000000..598d7b4 --- /dev/null +++ b/tests/opencart_sample_data_3.sql @@ -0,0 +1,55 @@ +TRUNCATE TABLE `oc_customer`; +INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `language_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `password`, `salt`, `cart`, `wishlist`, `newsletter`, `address_id`, `custom_field`, `ip`, `status`, `safe`, `token`, `code`, `date_added`) VALUES ('1', '1', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', 'ed3798da75d6cdd695e99e87a60d587a10aa95ff', '51TalnrgH', '', '', '0', '1', '', '172.21.0.1', '1', '0', '', '', '2018-06-07 13:50:08'); + +TRUNCATE TABLE `oc_customer_activity`; +TRUNCATE TABLE `oc_customer_group`; +INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('1', '0', '1'); +INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('2', '0', '1'); +INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('3', '0', '0'); + +TRUNCATE TABLE `oc_customer_group_description`; +INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('1', '1', 'Default', 'test'); +INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('2', '1', 'Test2', 'test2'); +INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('3', '1', 'test3', 'test3'); + +TRUNCATE TABLE `oc_customer_history`; +TRUNCATE TABLE `oc_customer_ip`; +INSERT INTO `oc_customer_ip` (`customer_ip_id`, `customer_id`, `ip`, `date_added`) VALUES ('4', '1', '172.21.0.1', '2018-06-07 13:50:29'); + +TRUNCATE TABLE `oc_customer_login`; +TRUNCATE TABLE `oc_customer_online`; +TRUNCATE TABLE `oc_customer_reward`; +TRUNCATE TABLE `oc_customer_search`; +TRUNCATE TABLE `oc_customer_transaction`; +TRUNCATE TABLE `oc_customer_wishlist`; +TRUNCATE TABLE `oc_order`; + +INSERT INTO `oc_order` (`order_id`, `invoice_no`, `invoice_prefix`, `store_id`, `store_name`, `store_url`, `customer_id`, `customer_group_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `custom_field`, `payment_firstname`, `payment_lastname`, `payment_company`, `payment_address_1`, `payment_address_2`, `payment_city`, `payment_postcode`, `payment_country`, `payment_country_id`, `payment_zone`, `payment_zone_id`, `payment_address_format`, `payment_custom_field`, `payment_method`, `payment_code`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address_1`, `shipping_address_2`, `shipping_city`, `shipping_postcode`, `shipping_country`, `shipping_country_id`, `shipping_zone`, `shipping_zone_id`, `shipping_address_format`, `shipping_custom_field`, `shipping_method`, `shipping_code`, `comment`, `total`, `order_status_id`, `affiliate_id`, `commission`, `marketing_id`, `tracking`, `language_id`, `currency_id`, `currency_code`, `currency_value`, `ip`, `forwarded_ip`, `user_agent`, `accept_language`, `date_added`, `date_modified`) VALUES ('1', '0', 'INV-2016-00', '0', 'Opencart', 'http://localhost:8000/', '1', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', '', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Cash on delivery', 'cod', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Flat Rate', 'flat.flat', 'test comment', '106.0000', '1', '0', '0.0000', '0', '', '1', '1', 'USD', '1.00000000', '172.21.0.1', '', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', '2018-06-07 13:51:10', '2018-06-07 13:51:23'); +INSERT INTO `oc_order` (`order_id`, `invoice_no`, `invoice_prefix`, `store_id`, `store_name`, `store_url`, `customer_id`, `customer_group_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `custom_field`, `payment_firstname`, `payment_lastname`, `payment_company`, `payment_address_1`, `payment_address_2`, `payment_city`, `payment_postcode`, `payment_country`, `payment_country_id`, `payment_zone`, `payment_zone_id`, `payment_address_format`, `payment_custom_field`, `payment_method`, `payment_code`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address_1`, `shipping_address_2`, `shipping_city`, `shipping_postcode`, `shipping_country`, `shipping_country_id`, `shipping_zone`, `shipping_zone_id`, `shipping_address_format`, `shipping_custom_field`, `shipping_method`, `shipping_code`, `comment`, `total`, `order_status_id`, `affiliate_id`, `commission`, `marketing_id`, `tracking`, `language_id`, `currency_id`, `currency_code`, `currency_value`, `ip`, `forwarded_ip`, `user_agent`, `accept_language`, `date_added`, `date_modified`) VALUES ('2', '0', 'INV-2016-00', '0', 'Opencart', 'http://localhost:8000/', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', '[]', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Cash on delivery', 'cod', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Flat Rate', 'flat.flat', 'test comment', '85.0000', '1', '0', '0.0000', '0', '', '1', '1', 'USD', '1.00000000', '172.21.0.1', '', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', '2018-06-07 13:53:50', '2018-06-07 13:54:00'); + +TRUNCATE TABLE `oc_order_history`; +INSERT INTO `oc_order_history` (`order_history_id`, `order_id`, `order_status_id`, `notify`, `comment`, `date_added`) VALUES ('19', '2', '1', '0', '', '2018-06-07 13:54:00'); +INSERT INTO `oc_order_history` (`order_history_id`, `order_id`, `order_status_id`, `notify`, `comment`, `date_added`) VALUES ('18', '1', '1', '0', '', '2018-06-07 13:51:23'); + +TRUNCATE TABLE `oc_order_option`; + +INSERT INTO `oc_order_option` (`order_option_id`, `order_id`, `order_product_id`, `product_option_id`, `product_option_value_id`, `name`, `value`, `type`) VALUES ('15', '2', '55', '226', '15', 'Select', 'Red', 'select'); + +TRUNCATE TABLE `oc_order_product`; +INSERT INTO `oc_order_product` (`order_product_id`, `order_id`, `product_id`, `name`, `model`, `quantity`, `price`, `total`, `tax`, `reward`) VALUES ('54', '1', '40', 'iPhone', 'product 11', '1', '101.0000', '101.0000', '18.0000', '20'); +INSERT INTO `oc_order_product` (`order_product_id`, `order_id`, `product_id`, `name`, `model`, `quantity`, `price`, `total`, `tax`, `reward`) VALUES ('55', '2', '30', 'Canon EOS 5D', 'Product 3', '1', '80.0000', '80.0000', '18.0000', '200'); + +TRUNCATE TABLE `oc_order_recurring`; +TRUNCATE TABLE `oc_order_recurring_transaction`; +TRUNCATE TABLE `oc_order_total`; + +INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('162', '1', 'shipping', 'Flat Rate', '5.0000', '3'); +INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('161', '1', 'sub_total', 'Sub-Total', '101.0000', '1'); +INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('164', '2', 'sub_total', 'Sub-Total', '80.0000', '1'); +INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('165', '2', 'shipping', 'Flat Rate', '5.0000', '3'); +INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9'); +INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9'); +INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('42', '2', '1', '110.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY)); +INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('40', '1', '1', '50.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY)); + +TRUNCATE TABLE `oc_order_voucher`;