From 31aafde3e58346e2dae098e103239b95c7fc503b Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Mon, 25 Sep 2023 09:27:47 +0300 Subject: [PATCH] ref #88027 Update Git Action tests (#218) --- .docker/Dockerfile | 14 ++---- .github/workflows/presta.yml | 22 +++++----- CHANGELOG.md | 3 ++ Makefile | 68 +++++++++--------------------- VERSION | 2 +- docker-compose.yml | 9 ++-- phpunit.xml.dist | 3 ++ retailcrm/retailcrm.php | 2 +- tests/lib/RetailcrmHistoryTest.php | 2 + 9 files changed, 46 insertions(+), 79 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index d1fca5ef..fe3a0e6f 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -2,10 +2,9 @@ FROM php:7.2-fpm RUN apt-get update -RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev unzip\ +RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev unzip nano\ && docker-php-ext-configure intl \ && docker-php-ext-install intl \ - && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ && docker-php-ext-install mysqli pdo pdo_mysql \ && docker-php-ext-install zip \ && docker-php-ext-install xml \ @@ -18,14 +17,7 @@ RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-de && pecl install mcrypt-1.0.1 \ && docker-php-ext-enable mcrypt -RUN apt-get install -y wget - -RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-6.phar && chmod +x /usr/bin/phpunit -RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer - -# Set timezone -RUN rm /etc/localtime -RUN ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime -RUN "date" +RUN curl -sSL https://phar.phpunit.de/phpunit-6.phar -o /usr/bin/phpunit && chmod +x /usr/bin/phpunit \ + && curl -sSL https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer WORKDIR /code \ No newline at end of file diff --git a/.github/workflows/presta.yml b/.github/workflows/presta.yml index 0d9a463c..ab68a96d 100644 --- a/.github/workflows/presta.yml +++ b/.github/workflows/presta.yml @@ -17,21 +17,19 @@ jobs: - php-version: '7.1' branch: '1.7.7.0' composerv1: 1 - phpunit-version: 'phpunit:6.4.3' - php-version: '7.2' branch: '1.7.7.0' composerv1: 1 - phpunit-version: 'phpunit:6.4.3' - - php-version: '7.1' - branch: '1.7.7.8' - composerv1: 1 - phpunit-version: 'phpunit:6.4.3' - - php-version: '7.2' - branch: '1.7.7.8' + - php-version: '7.3' + branch: '1.7.7.0' composerv1: 1 + - php-version: '7.1' + branch: '1.7.8.10' coverage: 1 - phpunit-version: 'phpunit:6.4.3' - + - php-version: '7.2' + branch: '1.7.8.10' + - php-version: '7.3' + branch: '1.7.8.10' services: mysql: image: mysql:5.7 @@ -47,7 +45,7 @@ jobs: with: php-version: ${{ matrix.php-version }} coverage: xdebug - tools: composer:v2, ${{ matrix.phpunit-version }} + tools: composer:v2, phpunit:6.4.3 extensions: gd, mbstring, zip, mcrypt, pdo_mysql, dom - name: Start mysql service run: sudo /etc/init.d/mysql start @@ -60,7 +58,7 @@ jobs: BRANCH: ${{ matrix.branch }} COMPOSERV1: ${{ matrix.composerv1 }} MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }} - run: make before_script + run: make install_prestashop - name: Run tests env: BRANCH: ${{ matrix.branch }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 92ab3aa8..6a29713a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v3.6.1 +* Добавлены тесты для новых версий PrestaShop + ## v3.6.0 * Добавлена поддержка PrestaShop 1.7.8.10 diff --git a/Makefile b/Makefile index ca6e6c0c..fd60cdb5 100644 --- a/Makefile +++ b/Makefile @@ -14,62 +14,34 @@ delete_archive: rm -f $(ARCHIVE_NAME) rm -f /tmp/retailcrm.zip -composer: clone_prestashop clone_composer fix-version-lang-bugs -ifeq ($(COMPOSERV1),1) - cd $(PRESTASHOP_DIR) && php composer.phar install --prefer-dist --no-interaction --no-progress -else - cd $(PRESTASHOP_DIR)/tests && composer install -endif - clone_prestashop: cd $(ROOT_DIR)/../ && git clone https://github.com/PrestaShop/PrestaShop cd $(PRESTASHOP_DIR) && git checkout $(BRANCH) -clone_composer: +# Required for versions 1.7.7.x - 1.7.8.x +# Only this command work in Makefile for replace $sfContainer->get('translator') +# sed -i 's/$$sfContainer->get('"'"'translator'"'"')/Context::getContext()->getTranslator()/g' classes/Language.php +fix_lang_bugs: + cd $(PRESTASHOP_DIR) && sed -i \ + -e "s/throw new Exception/#throw new Exception/g" \ + -e "s/SymfonyContainer::getInstance()->get('translator')/Context::getContext()->getTranslator()/g" \ + -e 's/$$sfContainer->get('"'"'translator'"'"')/Context::getContext()->getTranslator()/g' \ + src/PrestaShopBundle/Install/DatabaseDump.php classes/lang/DataLang.php classes/Language.php + +install_composer: +# Required for versions 1.7.7.x ifeq ($(COMPOSERV1),1) - cd $(PRESTASHOP_DIR) \ - && php -r "copy('https://getcomposer.org/download/1.10.17/composer.phar', 'composer.phar');" + composer self-update --1 endif + cd $(PRESTASHOP_DIR) && composer install -before_script: composer -ifneq ("$(wildcard $(PRESTASHOP_DIR)/travis-scripts/install-prestashop)","") - ifeq ($(COMPOSERV1),1) - cd $(PRESTASHOP_DIR) \ - && sed -i 's/mysql -u root/mysql -u root --port $(MYSQL_PORT)/g' travis-scripts/install-prestashop \ - && sed -i 's/--db_server=127.0.0.1 --db_name=prestashop/--db_server=127.0.0.1:$(MYSQL_PORT) --db_name=prestashop --db_user=root/g' travis-scripts/install-prestashop \ - && bash travis-scripts/install-prestashop - else - cd $(PRESTASHOP_DIR) \ - && sed -i 's/mysql -u root/mysql -u root -proot --port $(MYSQL_PORT)/g' travis-scripts/install-prestashop.sh \ - && sed -i 's/--db_server=127.0.0.1 --db_name=prestashop/--db_server=127.0.0.1:$(MYSQL_PORT) --db_name=prestashop --db_user=root/g' travis-scripts/install-prestashop.sh \ - && bash travis-scripts/install-prestashop.sh - endif -else - rm -rf var/cache/* - echo "* Installing PrestaShop, this may take a while ..."; - +install_prestashop: clone_prestashop fix_lang_bugs install_composer 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 + mkdir coverage endif -endif - -# Required for versions 1.7.7.x -fix-version-lang-bugs: -ifeq ($(COMPOSERV1),1) - cd $(PRESTASHOP_DIR) \ - && sed -i 's/throw new Exception/#throw new Exception/g' src/PrestaShopBundle/Install/DatabaseDump.php -endif - - cd $(PRESTASHOP_DIR) \ - && sed -i "s/SymfonyContainer::getInstance()->get('translator')/\\\\Context::getContext()->getTranslator()/g" classes/lang/DataLang.php - cat $(PRESTASHOP_DIR)/classes/lang/DataLang.php | grep -A 3 -B 3 'this->translator = ' - - cd $(PRESTASHOP_DIR) \ - && sed -i "s/SymfonyContainer::getInstance()->get('translator')/\\\\Context::getContext()->getTranslator()/g" classes/Language.php - cat $(PRESTASHOP_DIR)/classes/Language.php | grep -A 3 -B 3 'translator = ' lint: php-cs-fixer fix --config=$(ROOT_DIR)/.php-cs-fixer.php -v @@ -77,11 +49,11 @@ lint: lint-docker: docker run --rm -it -w=/app -v ${PWD}:/app oskarstark/php-cs-fixer-ga:latest --config=.php-cs-fixer.php -v - # todo moveto version test: + cd $(PRESTASHOP_DIR) && composer run-script create-test-db --timeout=0 + ifeq ($(COMPOSERV1),1) - cd $(PRESTASHOP_DIR) && php composer.phar run-script create-test-db --timeout=0 - cd $(PRESTASHOP_DIR) && php vendor/bin/phpunit -c $(ROOT_DIR)/phpunit.xml.dist + phpunit -c $(ROOT_DIR)/phpunit.xml.dist else phpunit -c phpunit.xml.dist endif @@ -91,5 +63,5 @@ coverage: run_local_tests: docker-compose up -d --build - docker exec app_test make before_script test + docker exec app_prestashop_test make install_prestashop test docker-compose down diff --git a/VERSION b/VERSION index 40c341bd..9575d51b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.6.0 +3.6.1 diff --git a/docker-compose.yml b/docker-compose.yml index 423b8333..35dae414 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,22 +1,19 @@ version: '3' services: app: - container_name: app_test + container_name: app_prestashop_test build: context: ./.docker volumes: - ./:/code env_file: - ./.env - environment: - - BRANCH=${BRANCH} - links: - - db depends_on: - db db: + container_name: mysql_prestashop_test image: mysql:5.7 environment: - MYSQL_ALLOW_EMPTY_PASSWORD=yes ports: - - "3306:3306" + - '3306:3306' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f47d6f36..f92596bf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -17,6 +17,9 @@ tests/helpers + + + retailcrm diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php index 892f1345..f0710c49 100755 --- a/retailcrm/retailcrm.php +++ b/retailcrm/retailcrm.php @@ -48,7 +48,7 @@ class RetailCRM extends Module { - const VERSION = '3.6.0'; + const VERSION = '3.6.1'; const API_URL = 'RETAILCRM_ADDRESS'; const API_KEY = 'RETAILCRM_API_TOKEN'; diff --git a/tests/lib/RetailcrmHistoryTest.php b/tests/lib/RetailcrmHistoryTest.php index 2578b03d..b7c91ba5 100644 --- a/tests/lib/RetailcrmHistoryTest.php +++ b/tests/lib/RetailcrmHistoryTest.php @@ -496,6 +496,8 @@ public function testPaymentStatusUpdate() RetailcrmHistory::$api = $this->apiMock; RetailcrmHistory::ordersHistory(); + + $this->assertTrue(true); } public function testOrderAddressUpdate()