From ad60c20cf9315dcf7465166e896be9b81b0d9443 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 30 May 2018 09:58:53 +0300 Subject: [PATCH] Update travis config for run tests --- .travis.yml | 31 +++++++++++++++-------- retailcrm/retailcrm.php | 2 +- tests/bin/before_script.sh | 11 ++++++++ tests/bin/clone_prestashop.sh | 2 ++ tests/bin/script.sh | 9 +++++-- tests/helpers/RetailcrmTestCase.php | 6 +++-- tests/phpunit/RetailcrmReferencesTest.php | 11 +++++--- 7 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 tests/bin/before_script.sh diff --git a/.travis.yml b/.travis.yml index 6a17278..bf9d0d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,23 +4,34 @@ sudo: false php: - 5.6 + - 7.0 + - 7.1 + - 7.2 -env: - global: - - DB_USER=root - - DB_HOST=localhost - - DB_NAME=test_prestashop +matrix: + include: + - php: 5.3 + dist: precise + env: BRANCH=1.6.1.x + - php: 5.4 + env: BRANCH=1.6.1.x + - php: 5.5 + env: BRANCH=1.6.1.x + - php: 5.6 + env: BRANCH=1.6.1.x + - php: 7.0 + env: BRANCH=1.6.1.x + - php: 7.1 + env: BRANCH=1.6.1.x + - php: 7.2 + env: BRANCH=1.6.1.x before_script: - bash tests/bin/clone_prestashop.sh - - cd ../PrestaShop - - cp tests/parameters.yml.travis app/config/parameters.yml - - bash travis-scripts/install-prestashop + - bash tests/bin/before_script.sh script: - - cd $TRAVIS_BUILD_DIR - bash tests/bin/script.sh - - php ../PrestaShop/vendor/bin/phpunit -c phpunit.xml.dist deploy: skip_cleanup: true diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php index 2275803..3e2ec69 100644 --- a/retailcrm/retailcrm.php +++ b/retailcrm/retailcrm.php @@ -580,7 +580,7 @@ class RetailCRM extends Module } else { $paymentCode = $params['order']->payment; } -var_dump($paymentCode); + if ($this->apiVersion != 5) { if (array_key_exists($paymentCode, $payment) && !empty($payment[$paymentCode])) { $order['paymentType'] = $payment[$paymentCode]; diff --git a/tests/bin/before_script.sh b/tests/bin/before_script.sh new file mode 100644 index 0000000..05799b4 --- /dev/null +++ b/tests/bin/before_script.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +if [ -z $TRAVIS_BUILD_DIR ]; then + exit 0; +fi + +PRESTASHOP_DIR=$TRAVIS_BUILD_DIR/../PrestaShop + +cd $PRESTASHOP_DIR +cp tests/parameters.yml.travis app/config/parameters.yml +bash travis-scripts/install-prestashop diff --git a/tests/bin/clone_prestashop.sh b/tests/bin/clone_prestashop.sh index 4413ab9..fde2403 100644 --- a/tests/bin/clone_prestashop.sh +++ b/tests/bin/clone_prestashop.sh @@ -12,6 +12,8 @@ cd PrestaShop if ! [ -z $BRANCH ]; then git checkout $BRANCH; + cd tests + composer install else composer install --prefer-dist --no-interaction --no-progress fi diff --git a/tests/bin/script.sh b/tests/bin/script.sh index 58c2c7b..a104a9e 100644 --- a/tests/bin/script.sh +++ b/tests/bin/script.sh @@ -6,5 +6,10 @@ fi PRESTASHOP_DIR=$TRAVIS_BUILD_DIR/../PrestaShop -cd $PRESTASHOP_DIR -composer run-script create-test-db --timeout=0 +if ! [ -z $BRANCH ]; then + phpunit +else + cd $PRESTASHOP_DIR + composer run-script create-test-db --timeout=0 + php ../PrestaShop/vendor/bin/phpunit -c $TRAVIS_BUILD_DIR/phpunit.xml.dist +fi diff --git a/tests/helpers/RetailcrmTestCase.php b/tests/helpers/RetailcrmTestCase.php index a274f40..10a33e6 100644 --- a/tests/helpers/RetailcrmTestCase.php +++ b/tests/helpers/RetailcrmTestCase.php @@ -8,8 +8,10 @@ abstract class RetailcrmTestCase extends \PHPUnit\Framework\TestCase { parent::setUp(); - $contextMocker = new \Tests\Unit\ContextMocker(); - $this->contextMock = $contextMocker->mockContext(); + if (version_compare(_PS_VERSION_, '1.7', '>')) { + $contextMocker = new \Tests\Unit\ContextMocker(); + $this->contextMock = $contextMocker->mockContext(); + } } protected function setConfig() diff --git a/tests/phpunit/RetailcrmReferencesTest.php b/tests/phpunit/RetailcrmReferencesTest.php index 0d9904d..64acd5c 100644 --- a/tests/phpunit/RetailcrmReferencesTest.php +++ b/tests/phpunit/RetailcrmReferencesTest.php @@ -24,10 +24,13 @@ class RetailcrmReferencesTest extends RetailcrmTestCase public function testGetSystemPaymentModules() { $this->assertInternalType('array', $this->retailcrmReferences->payment_modules); - $this->assertNotEmpty($this->retailcrmReferences->payment_modules); - $this->assertArrayHasKey('name', $this->retailcrmReferences->payment_modules[0]); - $this->assertArrayHasKey('code', $this->retailcrmReferences->payment_modules[0]); - $this->assertArrayHasKey('id', $this->retailcrmReferences->payment_modules[0]); + + if (version_compare(_PS_VERSION_, '1.7', '>')) { + $this->assertNotEmpty($this->retailcrmReferences->payment_modules); + $this->assertArrayHasKey('name', $this->retailcrmReferences->payment_modules[0]); + $this->assertArrayHasKey('code', $this->retailcrmReferences->payment_modules[0]); + $this->assertArrayHasKey('id', $this->retailcrmReferences->payment_modules[0]); + } } public function testGetStatuses()