Fix local tests

This commit is contained in:
uryvskiy-dima 2023-01-09 10:13:54 +03:00
parent f5e5b15d56
commit ccdf9c4a1a
8 changed files with 49 additions and 41 deletions

View file

@ -1,8 +1,8 @@
FROM php:7.1-fpm
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 \
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\
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
@ -11,15 +11,16 @@ RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-de
&& docker-php-ext-install xml \
&& docker-php-ext-configure gd --with-png-dir=/usr/local/ --with-jpeg-dir=/usr/local/ --with-freetype-dir=/usr/local/ \
&& docker-php-ext-install gd \
&& docker-php-ext-install mcrypt \
&& docker-php-ext-install bcmath \
&& docker-php-ext-install soap \
&& docker-php-ext-install xsl \
&& docker-php-ext-install mbstring
&& docker-php-ext-install mbstring \
&& 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-7.phar && chmod +x /usr/bin/phpunit
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

7
.env.dist Normal file
View file

@ -0,0 +1,7 @@
#PrestaShop git branch
BRANCH=1.7.4.4
#For version 1.7.x you need to use composer v1
COMPOSERV1=1
LOCAL_TEST=1

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ upgrade/upgrade-*.php
!upgrade/upgrade-sample.php
coverage.xml
.php-cs-fixer.cache
.env

View file

@ -31,19 +31,7 @@ ifeq ($(COMPOSERV1),1)
&& php -r "copy('https://getcomposer.org/download/1.10.17/composer.phar', 'composer.phar');"
endif
setup_apache:
bash $(PRESTASHOP_DIR)/travis-scripts/setup-php-fpm.sh
echo "* Preparing Apache ..."
sudo a2enmod rewrite actions fastcgi alias
# Use default config
sudo cp -f $(PRESTASHOP_DIR)/tests/travis-ci-apache-vhost /etc/apache2/sites-available/000-default.conf
sudo sed -e "s?%PRESTASHOP_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
sudo chmod 777 -R $(HOME)
# Starting Apache
sudo service apache2 restart
before_script: composer
mkdir coverage
ifneq ("$(wildcard $(PRESTASHOP_DIR)/travis-scripts/install-prestashop)","")
ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) \
@ -57,10 +45,15 @@ ifneq ("$(wildcard $(PRESTASHOP_DIR)/travis-scripts/install-prestashop)","")
&& bash travis-scripts/install-prestashop.sh
endif
else
mysql -u root -proot --port $(MYSQL_PORT) -e "DROP DATABASE IF EXISTS \`prestashop\`;"
rm -rf var/cache/*
echo "* Installing PrestaShop, this may take a while ...";
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --language=en --country=fr --domain=localhost --db_server=127.0.0.1:$(MYSQL_PORT) --db_name=prestashop --db_user=root --db_create=1 --name=prestashop.unit.test --email=demo@prestashop.com --password=prestashop_demo
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
endif
endif
fix-version-bugs:
@ -73,9 +66,7 @@ ifeq ($(BRANCH), 1.7.4.4)
&& sed -i 's/$$install->installModules();/$$install->setTranslator(\\Context::getContext()->getTranslator());\n\t$$install->installModules();/g' tests/PrestaShopBundle/Utils/DatabaseCreator.php
cat $(PRESTASHOP_DIR)/tests/PrestaShopBundle/Utils/DatabaseCreator.php | grep -A 3 -B 3 'install->installModules()'
endif
#ifeq ($(BRANCH), 1.7.5.2)
# cd $(PRESTASHOP_DIR) && php composer.phar require --dev friendsofphp/php-cs-fixer:2.16.0 --prefer-dist --no-interaction --no-progress --no-scripts
#endif
ifeq ($(BRANCH),$(filter $(BRANCH),1.7.6.9 1.7.7.8))
cd $(PRESTASHOP_DIR) \
&& sed -i "s/SymfonyContainer::getInstance()->get('translator')/\\\\Context::getContext()->getTranslator()/g" classes/lang/DataLang.php
@ -103,3 +94,8 @@ endif
coverage:
wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml
run_local_tests:
docker-compose up -d --build
docker exec app_test make before_script test
docker-compose down

View file

@ -28,6 +28,12 @@ Module allows integrate CMS Prestashop with [Simla.com](https://simla.com) ([Doc
You can customize your module behavior using [Custom Filters](doc/3.%20Customization/Filters.md) or [Custom Classes](doc/3.%20Customization/Classes.md)
#### Local testing
To local testing:
* cp .env.dist .env
* make run_local_tests
#### Documentation
[Here](doc/README.md) you can find more information about module setup and workflow

View file

@ -1,25 +1,22 @@
version: '3'
services:
app:
container_name: app_test
build:
context: ./.docker
volumes:
- ./:/code
links:
- "mysql"
depends_on:
- mysql
env_file:
- ./.env
environment:
- DB_NAME=presta
- DB_USER=presta
- DB_PASS=presta
- DB_HOST=presta
mysql:
- BRANCH=${BRANCH}
links:
- db
depends_on:
- db
db:
image: mysql:5.7
environment:
- MYSQL_DATABASE=presta
- MYSQL_USER=presta
- MYSQL_PASSWORD=presta
- MYSQL_ROOT_PASSWORD=root
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
ports:
- "3306:3306"
- "3306:3306"

View file

@ -253,7 +253,7 @@ class RetailcrmCartUploader
$crmCart = [
'externalId' => $cartExternalId,
'customer' => ['externalId' => $cart->id_customer],
'clearAt'=> null,
'clearAt' => null,
'createdAt' => $cart->date_add,
'droppedAt' => date('Y-m-d H:i:s'),
];
@ -274,9 +274,9 @@ class RetailcrmCartUploader
? $product['id_product'] . '#' . $product['id_product_attribute']
: $product['id_product']
],
'quantity'=> $product['cart_quantity'],
'price'=> $product['price'],
'createdAt'=> $product['date_add'],
'quantity' => $product['cart_quantity'],
'price' => $product['price'],
'createdAt' => $product['date_add'],
];
}
} catch (Exception $exception) {

View file

@ -70,7 +70,7 @@ class RetailcrmAbandonedCartsEvent extends RetailcrmAbstractEvent implements Ret
$api = RetailcrmTools::getApiClient();
if ($api === null) {
if (null === $api) {
continue;
}