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 29d961b..177b463 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,7 @@ +os: linux language: php - dist: trusty -sudo: false - if: tag IS blank env: @@ -16,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: @@ -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/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 * Небольшие фиксы diff --git a/Makefile b/Makefile index d696803..5066fb9 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ 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 + (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 e7d36d4..7313c66 100644 --- a/tests/RoboFile.php +++ b/tests/RoboFile.php @@ -1,9 +1,6 @@ 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,12 +87,19 @@ 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(); + 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']); @@ -168,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 7287b2e..365b9fc 100644 --- a/tests/admin/ControllerRetailcrmAdminTest.php +++ b/tests/admin/ControllerRetailcrmAdminTest.php @@ -1,6 +1,6 @@ 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/ModelRetailcrmCustomerAdminTest.php b/tests/admin/ModelRetailcrmCustomerAdminTest.php index a35d462..c294b13 100644 --- a/tests/admin/ModelRetailcrmCustomerAdminTest.php +++ b/tests/admin/ModelRetailcrmCustomerAdminTest.php @@ -1,6 +1,6 @@ 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/admin/ModelRetailcrmOrderAdminTest.php b/tests/admin/ModelRetailcrmOrderAdminTest.php index 750bfa7..497eadc 100644 --- a/tests/admin/ModelRetailcrmOrderAdminTest.php +++ b/tests/admin/ModelRetailcrmOrderAdminTest.php @@ -1,6 +1,6 @@ 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/catalog/ModelRetailcrmCustomerCatalogTest.php b/tests/catalog/ModelRetailcrmCustomerCatalogTest.php index badcbc7..7fbf523 100644 --- a/tests/catalog/ModelRetailcrmCustomerCatalogTest.php +++ b/tests/catalog/ModelRetailcrmCustomerCatalogTest.php @@ -1,6 +1,6 @@