1
0
mirror of synced 2025-01-29 22:31:41 +03:00

Update CI build (#96)

* cli Bitrix installation
* update travis config
* update installer
This commit is contained in:
Akolzin Dmitry 2020-03-23 15:12:07 +03:00 committed by GitHub
parent bc64f8e1bd
commit 86a51c8401
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 1122 additions and 211 deletions

19
.docker/Dockerfile Executable file
View File

@ -0,0 +1,19 @@
FROM php:7.1-apache
RUN a2enmod rewrite
RUN set -xe \
&& apt-get update \
&& apt-get install -y --no-install-recommends wget unzip imagemagick libpng-dev libjpeg-dev \
libfreetype6-dev default-mysql-client libmcrypt-dev libicu-dev libxml2 libxml2-dev libmagickwand-dev \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir=/usr \
&& docker-php-ext-install opcache soap gd mbstring mysqli zip intl \
&& pecl install mcrypt-1.0.1 imagick-3.4.4 \
&& docker-php-ext-enable mcrypt imagick \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer
RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-7.phar && chmod +x /usr/bin/phpunit
WORKDIR /bitrix-module

27
.docker/php.ini Executable file
View File

@ -0,0 +1,27 @@
[php]
short_open_tag = On
display_errors = On
error_log = "/var/log/php/error.log"
error_reporting = E_ALL
log_errors = On
display_startup_errors = On
cgi.fix_pathinfo = 0
date.timezone = "Europe/Moscow"
mbstring.func_overload = 2
mbstring.internal_encoding = "UTF-8"
default_charset = utf-8
max_input_vars = 10000
post_max_size = 1024M
memory_limit = 256M
upload_max_filesize = 1024M
pcre.jit = 0
pcre.recursion_limit = 10485760
[opcache]
opcache.revalidate_freq = 0
opcache.validate_timestamps = 1
opcache.max_accelerated_files = 100000
opcache.memory_consumption = 512
opcache.interned_strings_buffer = 64
opcache.fast_shutdown = 1
opcache.error_log = "/var/log/php/opcache.log"

2
.env.dist Normal file → Executable file
View File

@ -2,3 +2,5 @@ DB_BITRIX_HOST=""
DB_BITRIX_LOGIN=""
DB_BITRIX_PASS=""
DB_BITRIX_NAME=""
BITRIX_PATH=/var/www/html
BITRIX_EDITION=small_business_encode

1
.gitignore vendored
View File

@ -12,3 +12,4 @@
/vendor/
.env
.phpunit.result.cache
/release/

70
.travis.yml Normal file → Executable file
View File

@ -1,13 +1,9 @@
os: linux
dist: trusty
language: php
sudo: false
services:
- mysql
php:
- 7.1
- 7.2
if: tag IS blank
env:
global:
@ -17,12 +13,58 @@ env:
- DB_BITRIX_NAME=bitrix
- BITRIX_PATH=$TRAVIS_BUILD_DIR/bitrix
stages:
- test
- deploy
install:
- echo 'short_open_tag = On' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo 'mbstring.func_overload = 2' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo 'mbstring.internal_encoding = "UTF-8"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- export LAST_TAG=`git describe --abbrev=0 --tags`
- export CURRENT_VERSION=v`php bin/bitrix-version`
before_script:
# Change MySQL root password
- echo "USE mysql;\nUPDATE user SET authentication_string=PASSWORD('root') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root
- make create_db
- make bitrix_install
- composer install
- bash tests/bin/before_script.sh
script: make test
script:
- make test
jobs:
include:
- php: 7.0
env: NOT_USE_VENDOR=1 BITRIX_EDITION=small_business_encode
after_success: bash <(curl -s https://codecov.io/bash)
- php: 7.1
env: BITRIX_EDITION=small_business_encode
- php: 7.2
env: BITRIX_EDITION=small_business_encode
- php: 7.3
env: BITRIX_EDITION=small_business_encode
- php: 7.0
env: NOT_USE_VENDOR=1 BITRIX_EDITION=business_encode
- php: 7.1
env: BITRIX_EDITION=business_encode
- php: 7.2
env: BITRIX_EDITION=business_encode
- php: 7.3
env: BITRIX_EDITION=business_encode
- stage: deploy
php: 7.1
before_script: export VERSION=`php bin/bitrix-version`
script: make build_release
before_deploy:
- export ARCHIVE_NAME=$TRAVIS_BUILD_DIR/release/$VERSION.tar.gz
- git config --local user.name "retailCRM"
- git config --local user.email "support@retailcrm.ru"
- export TRAVIS_TAG=v$VERSION
- git tag $TRAVIS_TAG
deploy:
provider: releases
token: $GITHUB_OAUTH_TOKEN
file: $ARCHIVE_NAME
skip_cleanup: true
on:
condition: "$LAST_TAG != $CURRENT_VERSION"
if: branch = master AND type = push AND fork = false
after_deploy: make cleanup

64
Makefile Normal file → Executable file
View File

@ -1,5 +1,61 @@
test: prepare_module
@php -d short_open_tag=On vendor/bin/phpunit -c phpunit.xml.dist
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
prepare_module:
@composer pre-module-install
test: prepare_module
ifeq ($(NOT_USE_VENDOR),1)
composer tests7
else
composer tests
endif
prepare_module: deps
composer pre-module-install
deps:
ifneq ($(NOT_USE_VENDOR),1)
composer install
endif
bitrix_install: download_bitrix
@echo "===== Installing Bitrix..."
@php bin/bitrix-install db_type
@php bin/bitrix-install requirement
@php bin/bitrix-install db_create
@php bin/bitrix-install main_module
@php bin/bitrix-install module
@php bin/bitrix-install admin
@php bin/bitrix-install load_module
@php bin/bitrix-install load_module_action
@php bin/bitrix-install finish
download_bitrix:
ifeq ("$(wildcard $(BITRIX_PATH)/bitrix/php_interface/dbconn.php)","")
wget -O /tmp/$(BITRIX_EDITION).tar.gz https://www.1c-bitrix.ru/download/$(BITRIX_EDITION).tar.gz
mkdir -p $(BITRIX_PATH)
chmod -R 777 $(BITRIX_PATH)
tar -xf /tmp/$(BITRIX_EDITION).tar.gz -C $(BITRIX_PATH)
rm /tmp/$(BITRIX_EDITION).tar.gz
endif
create_db:
echo "USE mysql;\nUPDATE user SET password=PASSWORD('root') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root
mysqladmin create $(DB_BITRIX_NAME) --user=$(DB_BITRIX_LOGIN) --password=$(DB_BITRIX_PASS)
build_release: build_release_dir
bash bin/build $(VERSION) $(ROOT_DIR)/release/
build_release_dir: build_diff_file
php bin/build-release
build_diff_file:
git diff --name-status $(LAST_TAG) HEAD > $(ROOT_DIR)/release/diff
cleanup:
@rm -rf $(ROOT_DIR)/release/$(VERSION)
@rm $(ROOT_DIR)/release/$(VERSION).tar.gz
# docker commands
install:
docker-compose exec bitrix make bitrix_install
run_tests:
docker-compose exec bitrix make test

55
bin/bitrix-install Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env php
<?php
set_time_limit(0);
if (ini_get('memory_limit') > 0 && (int)ini_get('memory_limit') < 784) {
ini_set('memory_limit', '784M');
}
$_SERVER['DOCUMENT_ROOT'] = getenv('BITRIX_PATH') ? getenv('BITRIX_PATH') : '/var/www/html';
define("B_PROLOG_INCLUDED", true);
define("DEBUG_MODE", true);
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizard/wizard.php')) {
throw new \RuntimeException('Bitrix`s install files is not exists');
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizard/wizard.php';
require_once __DIR__ . '/../helpers/installation/ExtendedCreateModulesStep.php';
require_once __DIR__ . '/../helpers/installation/Installer.php';
$installer = new Installer();
$step = $argv[1];
switch ($step) {
case 'db_type':
$installer->dbTypeStep();
exit(0);
case 'requirement':
$installer->requirementStep();
exit(0);
case 'db_create':
$installer->createDBStep();
exit(0);
case 'main_module':
$installer->createModulesStep(true);
exit(0);
case 'module':
$installer->createModulesStep();
exit(0);
case 'admin':
$installer->createAdminStep();
exit(0);
case 'load_module':
$installer->createLoadModuleStep();
exit(0);
case 'load_module_action':
$installer->createLoadModuleActionStep();
exit(0);
case 'finish':
$installer->createFinishStep();
exit(0);
}

13
bin/bitrix-version Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php
set_time_limit(0);
if (ini_get('memory_limit') > 0 && (int)ini_get('memory_limit') < 784) {
ini_set('memory_limit', '784M');
}
require_once __DIR__ . '/../intaro.retailcrm/install/version.php';
echo $arModuleVersion['VERSION'];
exit(0);

40
bin/build Normal file
View File

@ -0,0 +1,40 @@
#!/bin/bash
# $1 -- folder name to pack;
version=$1
dir=${2-$PWD}
cd $dir
date=`date +"%Y-%m-%d %H:%M:%S"`
if [ ! -d "$version/install" ]; then
mkdir -p "./$version/install"
echo "Created a folder \"install\""
fi
if [ ! -f "$version/install/version.php" ]; then
touch "./$version/install/version.php"
echo "Created a file \"version.php\""
fi
echo "
<?
\$arModuleVersion = array(
\"VERSION\" => \"$version\",
\"VERSION_DATE\" => \"$date\"
);
" > "./$version/install/version.php"
echo "Update version and date in the file \"version.php\""
for i in `find ./"$version" -type f -name '*.*'`; do
encoding=`file -b --mime-encoding "$i"`
if [ "$encoding" != "iso-8859-1" ] && [ "$encoding" != "binary" ]; then
iconv -f $encoding -t "cp1251" $i >> $i.cp1251
mv $i.cp1251 $i
fi
done
echo "Encoding the file has changed"
tar -czf $version.tar.gz $version
echo "Update has been successfully packaged"

40
bin/build-release Normal file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env php
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
require_once __DIR__ . '/../helpers/release/ReleaseBuilder.php';
require_once __DIR__ . '/../helpers/release/ModifiedFile.php';
require_once __DIR__ . '/../intaro.retailcrm/install/version.php';
define('RELEASE_DIR', __DIR__ . '/../release/');
define('ORIGINAL', __DIR__ . '/../intaro.retailcrm/');
if (!file_exists(RELEASE_DIR . 'diff')) {
print('Diff file does not exists');
exit(255);
}
$handle = fopen(RELEASE_DIR . 'diff', 'r');
if (!$handle) {
exit(255);
}
$modifiedFiles = [];
while (($buffer = fgets($handle)) !== false) {
$file = explode("\t", trim($buffer));
$modifiedFile = new ModifiedFile($file[1], $file[0]{0});
$modifiedFiles[] = $modifiedFile;
}
try {
$builder = new ReleaseBuilder($modifiedFiles, $arModuleVersion['VERSION']);
$builder->build();
} catch(\Exception $exception) {
print($exception->getMessage());
exit(255);
}
exit(0);

7
composer.json Normal file → Executable file
View File

@ -1,7 +1,9 @@
{
"name": "retailcrm/bitrix-module",
"scripts": {
"pre-module-install": "cp -R intaro.retailcrm $BITRIX_PATH/bitrix/modules"
"pre-module-install": "cp -R intaro.retailcrm $BITRIX_PATH/bitrix/modules",
"tests": "php vendor/bin/phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm",
"tests7": "phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm"
},
"description": "Integration module for Bitrix & RetailCRM",
"type": "bitrix-module",
@ -12,7 +14,8 @@
}
],
"require": {
"ext-json": "*"
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^7",

339
composer.lock generated
View File

@ -1,36 +1,37 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"hash": "ddd7e180547a8283bf5fddabd72ebb54",
"content-hash": "f2ec5e27e0c7d2048afbcf9ee8797987",
"content-hash": "9dd92e1798bfa1b664589fa3d38dd4da",
"packages": [],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.1.0",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda"
"reference": "ae466f726242e637cebdd526a7d991b9433bacf1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1",
"reference": "ae466f726242e637cebdd526a7d991b9433bacf1",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"doctrine/coding-standard": "^6.0",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "^6.2.3",
"squizlabs/php_codesniffer": "^3.0.2"
"phpbench/phpbench": "^0.13",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
@ -55,25 +56,25 @@
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"time": "2017-07-22 11:58:36"
"time": "2019-10-21T16:45:58+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.8.1",
"version": "1.9.5",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8"
"reference": "b2c28789e80a97badd14145fda39b545d83ca3ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef",
"reference": "b2c28789e80a97badd14145fda39b545d83ca3ef",
"shasum": ""
},
"require": {
@ -108,7 +109,7 @@
"object",
"object graph"
],
"time": "2018-06-11 23:09:50"
"time": "2020-01-17T21:11:47+00:00"
},
{
"name": "phar-io/manifest",
@ -163,7 +164,7 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"time": "2018-07-08 19:23:20"
"time": "2018-07-08T19:23:20+00:00"
},
{
"name": "phar-io/version",
@ -210,39 +211,37 @@
}
],
"description": "Library for handling version information and constraints",
"time": "2018-07-08 19:19:57"
"time": "2018-07-08T19:19:57+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "1.0.1",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6"
"reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a",
"reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a",
"shasum": ""
},
"require": {
"php": ">=5.5"
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^4.6"
"phpunit/phpunit": "~6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src"
]
"phpDocumentor\\Reflection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -264,31 +263,32 @@
"reflection",
"static analysis"
],
"time": "2017-09-11 18:02:19"
"time": "2018-08-07T13:53:10+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "4.3.0",
"version": "4.3.4",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "94fd0001232e47129dd3504189fa1c7225010d08"
"reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08",
"reference": "94fd0001232e47129dd3504189fa1c7225010d08",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c",
"reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c",
"shasum": ""
},
"require": {
"php": "^7.0",
"phpdocumentor/reflection-common": "^1.0.0",
"phpdocumentor/type-resolver": "^0.4.0",
"phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0",
"phpdocumentor/type-resolver": "~0.4 || ^1.0.0",
"webmozart/assert": "^1.0"
},
"require-dev": {
"doctrine/instantiator": "~1.0.5",
"doctrine/instantiator": "^1.0.5",
"mockery/mockery": "^1.0",
"phpdocumentor/type-resolver": "0.4.*",
"phpunit/phpunit": "^6.4"
},
"type": "library",
@ -315,41 +315,40 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2017-11-30 07:14:17"
"time": "2019-12-28T18:55:12+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "0.4.0",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7"
"reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9",
"reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9",
"shasum": ""
},
"require": {
"php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0"
"php": "^7.1",
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^5.2||^4.8.24"
"ext-tokenizer": "^7.1",
"mockery/mockery": "~1",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src/"
]
"phpDocumentor\\Reflection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -362,47 +361,53 @@
"email": "me@mikevanriel.com"
}
],
"time": "2017-07-14 14:27:02"
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"time": "2019-08-22T18:11:29+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.5.0",
"version": "1.7.2",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
"reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed"
"reference": "77f7c4d2e65413aff5b5a8cc8b3caf7a28d81959"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/94e644f7d2051a5f0fcf77d81605f152eecff0ed",
"reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/77f7c4d2e65413aff5b5a8cc8b3caf7a28d81959",
"reference": "77f7c4d2e65413aff5b5a8cc8b3caf7a28d81959",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"php": "^5.5.9 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "4.7.*"
"bamarni/composer-bin-plugin": "^1.3",
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
"dev-master": "1.7-dev"
}
},
"autoload": {
"psr-0": {
"PhpOption\\": "src/"
"psr-4": {
"PhpOption\\": "src/PhpOption/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache2"
"Apache-2.0"
],
"authors": [
{
"name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com"
}
],
"description": "Option Type for PHP",
@ -412,42 +417,42 @@
"php",
"type"
],
"time": "2015-07-25 16:39:46"
"time": "2019-12-15T19:35:24+00:00"
},
{
"name": "phpspec/prophecy",
"version": "1.8.0",
"version": "v1.10.3",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06"
"reference": "451c3cd1418cf640de218914901e51b064abb093"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
"reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093",
"reference": "451c3cd1418cf640de218914901e51b064abb093",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
"sebastian/comparator": "^1.1|^2.0|^3.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0",
"sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0"
},
"require-dev": {
"phpspec/phpspec": "^2.5|^3.2",
"phpspec/phpspec": "^2.5 || ^3.2",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
"dev-master": "1.10.x-dev"
}
},
"autoload": {
"psr-0": {
"Prophecy\\": "src/"
"psr-4": {
"Prophecy\\": "src/Prophecy"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -475,7 +480,7 @@
"spy",
"stub"
],
"time": "2018-08-05 17:53:17"
"time": "2020-03-05T15:02:03+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -538,7 +543,7 @@
"testing",
"xunit"
],
"time": "2018-10-31 16:06:48"
"time": "2018-10-31T16:06:48+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -588,7 +593,7 @@
"filesystem",
"iterator"
],
"time": "2018-09-13 20:33:42"
"time": "2018-09-13T20:33:42+00:00"
},
{
"name": "phpunit/php-text-template",
@ -629,20 +634,20 @@
"keywords": [
"template"
],
"time": "2015-06-21 13:50:34"
"time": "2015-06-21T13:50:34+00:00"
},
{
"name": "phpunit/php-timer",
"version": "2.1.1",
"version": "2.1.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "8b389aebe1b8b0578430bda0c7c95a829608e059"
"reference": "1038454804406b0b5f5f520358e78c1c2f71501e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b389aebe1b8b0578430bda0c7c95a829608e059",
"reference": "8b389aebe1b8b0578430bda0c7c95a829608e059",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e",
"reference": "1038454804406b0b5f5f520358e78c1c2f71501e",
"shasum": ""
},
"require": {
@ -678,20 +683,20 @@
"keywords": [
"timer"
],
"time": "2019-02-20 10:12:59"
"time": "2019-06-07T04:22:29+00:00"
},
{
"name": "phpunit/php-token-stream",
"version": "3.0.1",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18"
"reference": "995192df77f63a59e47f025390d2d1fdf8f425ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18",
"reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff",
"reference": "995192df77f63a59e47f025390d2d1fdf8f425ff",
"shasum": ""
},
"require": {
@ -704,7 +709,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
@ -727,20 +732,20 @@
"keywords": [
"tokenizer"
],
"time": "2018-10-30 05:52:18"
"time": "2019-09-17T06:23:10+00:00"
},
{
"name": "phpunit/phpunit",
"version": "7.5.6",
"version": "7.5.20",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "09c85e14994df92e5ff1f5ec0b481bdb7d3d3df9"
"reference": "9467db479d1b0487c99733bb1e7944d32deded2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/09c85e14994df92e5ff1f5ec0b481bdb7d3d3df9",
"reference": "09c85e14994df92e5ff1f5ec0b481bdb7d3d3df9",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c",
"reference": "9467db479d1b0487c99733bb1e7944d32deded2c",
"shasum": ""
},
"require": {
@ -758,7 +763,7 @@
"phpunit/php-code-coverage": "^6.0.7",
"phpunit/php-file-iterator": "^2.0.1",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^2.0",
"phpunit/php-timer": "^2.1",
"sebastian/comparator": "^3.0",
"sebastian/diff": "^3.0",
"sebastian/environment": "^4.0",
@ -811,7 +816,7 @@
"testing",
"xunit"
],
"time": "2019-02-18 09:24:50"
"time": "2020-01-08T08:45:45+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -856,7 +861,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2017-03-04 06:30:41"
"time": "2017-03-04T06:30:41+00:00"
},
{
"name": "sebastian/comparator",
@ -920,7 +925,7 @@
"compare",
"equality"
],
"time": "2018-07-12 15:12:46"
"time": "2018-07-12T15:12:46+00:00"
},
{
"name": "sebastian/diff",
@ -976,20 +981,20 @@
"unidiff",
"unified diff"
],
"time": "2019-02-04 06:01:07"
"time": "2019-02-04T06:01:07+00:00"
},
{
"name": "sebastian/environment",
"version": "4.1.0",
"version": "4.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656"
"reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656",
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368",
"reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368",
"shasum": ""
},
"require": {
@ -1004,7 +1009,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-master": "4.2-dev"
}
},
"autoload": {
@ -1029,20 +1034,20 @@
"environment",
"hhvm"
],
"time": "2019-02-01 05:27:49"
"time": "2019-11-20T08:46:58+00:00"
},
{
"name": "sebastian/exporter",
"version": "3.1.0",
"version": "3.1.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "234199f4528de6d12aaa58b612e98f7d36adb937"
"reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937",
"reference": "234199f4528de6d12aaa58b612e98f7d36adb937",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e",
"reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e",
"shasum": ""
},
"require": {
@ -1069,6 +1074,10 @@
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
@ -1077,17 +1086,13 @@
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
@ -1096,7 +1101,7 @@
"export",
"exporter"
],
"time": "2017-04-03 13:19:02"
"time": "2019-09-14T09:02:43+00:00"
},
{
"name": "sebastian/global-state",
@ -1147,7 +1152,7 @@
"keywords": [
"global state"
],
"time": "2017-04-27 15:39:26"
"time": "2017-04-27T15:39:26+00:00"
},
{
"name": "sebastian/object-enumerator",
@ -1194,7 +1199,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2017-08-03 12:35:26"
"time": "2017-08-03T12:35:26+00:00"
},
{
"name": "sebastian/object-reflector",
@ -1239,7 +1244,7 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"time": "2017-03-29 09:07:27"
"time": "2017-03-29T09:07:27+00:00"
},
{
"name": "sebastian/recursion-context",
@ -1292,7 +1297,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2017-03-03 06:23:57"
"time": "2017-03-03T06:23:57+00:00"
},
{
"name": "sebastian/resource-operations",
@ -1334,7 +1339,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2018-10-04 04:07:39"
"time": "2018-10-04T04:07:39+00:00"
},
{
"name": "sebastian/version",
@ -1377,20 +1382,20 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03 07:35:21"
"time": "2016-10-03T07:35:21+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.10.0",
"version": "v1.14.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19"
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"shasum": ""
},
"require": {
@ -1402,7 +1407,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.14-dev"
}
},
"autoload": {
@ -1418,13 +1423,13 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
@ -1435,20 +1440,20 @@
"polyfill",
"portable"
],
"time": "2018-08-06 14:22:27"
"time": "2020-01-13T11:15:53+00:00"
},
{
"name": "theseer/tokenizer",
"version": "1.1.0",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
"reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b"
"reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b",
"reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9",
"reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9",
"shasum": ""
},
"require": {
@ -1475,20 +1480,20 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"time": "2017-04-07 12:08:54"
"time": "2019-06-13T22:48:21+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v3.3.2",
"version": "v3.6.1",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "1ee9369cfbf26cfcf1f2515d98f15fab54e9647a"
"reference": "8f7961f7b9deb3b432452c18093cf16f88205902"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1ee9369cfbf26cfcf1f2515d98f15fab54e9647a",
"reference": "1ee9369cfbf26cfcf1f2515d98f15fab54e9647a",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8f7961f7b9deb3b432452c18093cf16f88205902",
"reference": "8f7961f7b9deb3b432452c18093cf16f88205902",
"shasum": ""
},
"require": {
@ -1497,12 +1502,16 @@
"symfony/polyfill-ctype": "^1.9"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0"
"ext-filter": "*",
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
"dev-master": "3.6-dev"
}
},
"autoload": {
@ -1515,10 +1524,15 @@
"BSD-3-Clause"
],
"authors": [
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"homepage": "https://gjcampbell.co.uk/"
},
{
"name": "Vance Lucas",
"email": "vance@vancelucas.com",
"homepage": "http://www.vancelucas.com"
"homepage": "https://vancelucas.com/"
}
],
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
@ -1527,36 +1541,39 @@
"env",
"environment"
],
"time": "2019-01-30 10:43:17"
"funding": [
{
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
"type": "tidelift"
}
],
"time": "2020-03-12T13:44:00+00:00"
},
{
"name": "webmozart/assert",
"version": "1.4.0",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "83e253c8e0be5b0257b881e1827274667c5c17a9"
"reference": "aed98a490f9a8f78468232db345ab9cf606cf598"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9",
"reference": "83e253c8e0be5b0257b881e1827274667c5c17a9",
"url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598",
"reference": "aed98a490f9a8f78468232db345ab9cf606cf598",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"vimeo/psalm": "<3.6.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1"
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\Assert\\": "src/"
@ -1578,7 +1595,7 @@
"check",
"validate"
],
"time": "2018-12-25 11:19:39"
"time": "2020-02-14T12:15:55+00:00"
}
],
"aliases": [],
@ -1586,6 +1603,10 @@
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
"platform": {
"ext-json": "*",
"ext-mbstring": "*"
},
"platform-dev": [],
"plugin-api-version": "1.1.0"
}

32
docker-compose.yml Executable file
View File

@ -0,0 +1,32 @@
version: '3'
services:
bitrix:
build: ./.docker
env_file:
- .env
environment:
- MYSQL_SERVER=${DB_BITRIX_HOST}
- MYSQL_DATABASE=${DB_BITRIX_NAME}
- MYSQL_USER=${DB_BITRIX_LOGIN}
- MYSQL_PASSWORD=${DB_BITRIX_PASS}
- BITRIX_PATH=${BITRIX_PATH}
depends_on:
- mysql
ports:
- '8080:80'
links:
- mysql
volumes:
- ./:/bitrix-module
- ./.docker/php.ini:/usr/local/etc/php/conf.d/z-bitrix.ini
mysql:
env_file:
- .env
image: mysql:5.6
ports:
- '3306:3306'
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=${DB_BITRIX_NAME}
- MYSQL_USER=${DB_BITRIX_LOGIN}
- MYSQL_PASSWORD=${DB_BITRIX_PASS}

View File

@ -0,0 +1,15 @@
<?php
/**
* Class ExtendedCreateModulesStep
*/
class ExtendedCreateModulesStep extends CreateModulesStep
{
/**
* @param string $str
*/
public function SendResponse($str)
{
return;
}
}

View File

@ -0,0 +1,343 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizard/wizard.php';
/**
* Class Installer
*/
class Installer
{
private $dbName;
private $dbHost;
private $dbUser;
private $dbPass;
/**
* Installer constructor.
*/
public function __construct()
{
$this->deleteDefaultInstallation();
$this->dbHost = getenv('DB_BITRIX_HOST') ? getenv('DB_BITRIX_HOST') : 'localhost';
$this->dbName = getenv('DB_BITRIX_NAME') ? getenv('DB_BITRIX_NAME') : 'bitrix';
$this->dbUser = getenv('DB_BITRIX_LOGIN') ? getenv('DB_BITRIX_LOGIN') : 'bitrix';
$this->dbPass = getenv('DB_BITRIX_PASS') ? getenv('DB_BITRIX_PASS') : 'bitrix';
}
/**
* @param string $value
*/
private function setCurrentStepID($value)
{
$this->setRequestParam('CurrentStepID', $value);
}
/**
* @param string $value
*/
private function setNextStepID($value)
{
$this->setRequestParam('NextStepID', $value);
}
/**
* @param string $value
*/
private function setPreviousStepID($value)
{
$this->setRequestParam('PreviousStepID', $value);
}
/**
* @param string $key
* @param mixed $value
* @return self
*/
private function setRequestParam($key, $value)
{
$_REQUEST[$key] = $value;
$_POST[$key] = $value;
return $this;
}
/**
* Execute installation step
* @return void
*/
protected function request()
{
$this->setParams();
$steps = array(
CheckLicenseKey::class,
DBTypeStep::class,
RequirementStep::class,
CreateDBStep::class,
ExtendedCreateModulesStep::class,
CreateAdminStep::class,
SelectWizardStep::class,
LoadModuleStep::class,
LoadModuleActionStep::class,
SelectWizard1Step::class
);
$wizard = new CWizardBase(
str_replace("#VERS#", SM_VERSION, InstallGetMessage("INS_TITLE")),
$package = null
);
$wizard->AddSteps($steps);
$wizard->SetReturnOutput(true);
$wizard->Display();
foreach ($wizard->GetWizardSteps() as $step) {
if ($step->GetErrors()) {
foreach ($step->GetErrors() as $error) {
$this->println(sprintf('error: %s', mb_convert_encoding($error[0], 'UTF-8', 'windows-1251')));
}
}
}
}
/**
* Set request params for installation steps
* @return void
*/
private function setParams()
{
$params = array(
'__wiz_agree_license' => 'Y',
'__wiz_dbType' => 'mysql',
'__wiz_lic_key_variant' => '',
'__wiz_utf8' => 'Y',
'__wiz_create_user' => 'N',
'__wiz_host' => $this->dbHost,
'__wiz_user' => $this->dbUser,
'__wiz_password' => $this->dbPass,
'__wiz_database' => $this->dbName,
'__wiz_create_database' => 'N',
'__wiz_create_database_type' => 'innodb',
'__wiz_root_user' => '',
'__wiz_root_password' => '',
'__wiz_file_access_perms' => '0644',
'__wiz_folder_access_perms' => '0755',
'__wiz_login' => 'admin',
'__wiz_admin_password' => 'admin123',
'__wiz_admin_password_confirm' => 'admin123',
'__wiz_email' => 'admin@mail.com',
'__wiz_user_name' => '',
'__wiz_user_surname' => '',
'__wiz_selected_wizard' => 'bitrix.eshop:bitrix:eshop',
);
foreach ($params as $code => $param) {
$this->setRequestParam($code, $param);
}
}
/**
* Step of select database type
* @return self
*/
public function dbTypeStep()
{
$this->setCurrentStepID('select_database');
$this->setNextStepID('requirements');
ob_start();
$this->request();
ob_clean();
$this->println('Selected database type');
return $this;
}
/**
* Requirements step
* @return self
*/
public function requirementStep()
{
$this->setCurrentStepID('requirements');
$this->setNextStepID('create_database');
$this->request();
$this->println('Requirements step');
return $this;
}
/**
* Create database step
* @return self
*/
public function createDBStep()
{
$this->setCurrentStepID('create_database');
$this->setNextStepID('create_modules');
$this->request();
$this->println('Database setup');
return $this;
}
/**
* Installation modules step
* @param bool $isMain
* @return self
*/
public function createModulesStep($isMain = false)
{
$threeSteps = array(
'utf8',
'database',
'files'
);
if ($isMain) {
$modules = array(
'main' => $threeSteps
);
} else {
$modules = array(
'abtest' => $threeSteps,
'bitrix.eshop' => $threeSteps,
'catalog' => $threeSteps,
'compression' => $threeSteps,
'conversion' => $threeSteps,
'currency' => $threeSteps,
'fileman' => $threeSteps,
'form' => $threeSteps,
'highloadblock' => $threeSteps,
'iblock' => $threeSteps,
'pull' => $threeSteps,
'rest' => $threeSteps,
'sale' => $threeSteps,
'scale' => $threeSteps,
'search' => $threeSteps,
'security' => $threeSteps,
'sender' => $threeSteps,
'storeassist' => $threeSteps,
'translate' => $threeSteps,
'ui' => $threeSteps,
'remove_mysql' => array(
array('single')
),
'remove_mssql' => array(
array('single')
),
'remove_oracle' => array(
array('single')
),
'remove_misc' => array(
array('single')
),
'__finish' => array(
array('single')
)
);
}
$this->setCurrentStepID('create_modules');
foreach ($modules as $module => $steps) {
foreach ($steps as $step) {
$this->setRequestParam('__wiz_nextStep', $module);
$this->setRequestParam('__wiz_nextStepStage', $step);
$this->request();
$this->println(sprintf('%s module install, step %s', $module, $step));
}
}
return $this;
}
/**
* Create admin interface step
* @return self
*/
public function createAdminStep()
{
$this->setCurrentStepID('create_admin');
$this->request();
$this->println('Setup admin');
return $this;
}
/**
* Load modules step
* @return self
*/
public function createLoadModuleStep()
{
$this->setCurrentStepID('load_module');
$this->request();
$this->println('Load modules');
return $this;
}
/**
* Load modules action step
* @return self
*/
public function createLoadModuleActionStep()
{
$this->setCurrentStepID('load_module_action');
$this->request();
$this->println('Load modules action');
return $this;
}
/**
* Finish install step
* @return self
*/
public function createFinishStep()
{
$this->setCurrentStepID('finish');
$this->request();
$this->println('Installation finish');
return $this;
}
/**
* Remove code for web install
* @return void
*/
private function deleteDefaultInstallation()
{
$data = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizard/wizard.php');
$newData = preg_replace('/\$wizard= new CWizardBase.+$/', '', $data);
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizard/wizard.php', $newData);
}
/**
* @param string $string
* @return void
*/
private function println($string)
{
print($string);
print(PHP_EOL);
}
}

View File

@ -0,0 +1,93 @@
<?php
/**
* Class ModifiedFile
*/
class ModifiedFile
{
/** @var string */
const ADDED = 'A';
/** @var string */
const DELETED = 'D';
/** @var string */
const MODIFIED = 'M';
/** @var string */
const RENAMED = 'R';
/** @var string */
const MODULE_ID = 'intaro.retailcrm';
/** @var string */
const DESCRIPTION = 'description.ru';
/** @var string */
const VERSION = 'install/version.php';
/** @var string */
protected $filename;
/** @var string */
protected $modificator;
/**
* ModifiedFile constructor.
* @param string $filename
* @param string $modificator
*/
public function __construct($filename, $modificator = self::Modified)
{
$this->filename = $filename;
$this->modificator = $modificator;
}
/**
* @return bool
*/
public function isAdded()
{
return $this->modificator === static::ADDED;
}
/**
* @return bool
*/
public function isDeleted()
{
return $this->modificator === static::DELETED;
}
/**
* @return bool
*/
public function isModified()
{
return $this->modificator === static::MODIFIED;
}
/**
* @return bool
*/
public function isRenamed()
{
return $this->modificator === static::RENAMED;
}
/**
* @return bool
*/
public function isModuleFile()
{
return strpos($this->filename, static::MODULE_ID) === 0;
}
/**
* @return string
*/
public function getFilename()
{
return $this->filename;
}
}

View File

@ -0,0 +1,113 @@
<?php
require_once 'ModifiedFile.php';
/**
* Class ReleaseBuilder
*/
class ReleaseBuilder
{
/** @var ModifiedFile[] */
protected $files;
/** @var string */
protected $releaseDir;
/**
* ReleaseBuilder constructor.
* @param ModifiedFile[] $files
* @param string $releaseVersion
* @throws \RuntimeException
*/
public function __construct($files, $releaseVersion)
{
$this->files = $files;
if (!defined('RELEASE_DIR') || !defined('ORIGINAL')) {
throw new \RuntimeException('`RELEASE_DIR` or `ORIGINAL` not defined');
}
$this->releaseDir = RELEASE_DIR . $releaseVersion . '/';
}
/**
* @return void
*/
public function build()
{
$this->createReleaseDir();
$modifiedFiles = [];
foreach ($this->files as $file) {
if (!$file->isModuleFile() || $file->isDeleted()) {
continue;
}
$modifiedFiles[] = $this->getRealFilename($file->getFilename());
}
if (!in_array(ModifiedFile::DESCRIPTION, $modifiedFiles) || !in_array(ModifiedFile::VERSION, $modifiedFiles)) {
throw new \UnexpectedValueException('Version or description file does not exists');
}
if (empty($modifiedFiles)) {
throw new \LogicException('Not found modified files for release');
}
$this->createDirNodes($modifiedFiles);
$this->copyFiles($modifiedFiles);
}
/**
* @param string[] $files
*/
private function copyFiles($files)
{
foreach ($files as $file) {
copy(ORIGINAL . $file, $this->releaseDir . $file);
}
}
/**
* @param string[] $files
*/
private function createDirNodes($files)
{
$paths = [];
foreach ($files as $file) {
$dirs = explode('/', $file, -1);
$path = $this->releaseDir;
foreach ($dirs as $dir) {
$path .= $dir . '/';
$paths[] = $path;
}
}
foreach ($paths as $path) {
if (!file_exists($path)) {
mkdir($path, 0755);
}
}
}
/**
* @return void
*/
private function createReleaseDir()
{
if (!file_exists($this->releaseDir)) {
mkdir($this->releaseDir, 0755);
}
}
/**
* @param string $filename
* @return string
*/
private function getRealFilename($filename)
{
return str_replace(ModifiedFile::MODULE_ID . '/', '', $filename);
}
}

View File

@ -1,5 +1,5 @@
<?
$arModuleVersion = array(
"VERSION" => "5.2.5",
"VERSION_DATE" => "2020-01-09 12:02:00"
"VERSION_DATE" => "2020-01-09 12:02:00"
);

19
phpunit.xml.dist Normal file → Executable file
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="tests/phpunit/bootstrap.php"
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
@ -12,7 +12,22 @@
>
<testsuites>
<testsuite name="Retailcrm Bitrix module Test Suite">
<directory suffix=".php">tests/phpunit</directory>
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<exclude>
<directory suffix=".php">retailcrm/translations</directory>
<file>bootstrap.php</file>
<file>index.php</file>
<file>logo.gif</file>
<file>logo.png</file>
<file>objects.xml</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="coverage.xml"/>
</logging>
</phpunit>

0
release/.gitkeep Normal file
View File

View File

@ -1,21 +0,0 @@
#!/usr/bin/env bash
if [ -d $TRAVIS_BUILD_DIR ]; then
BITRIX_PATH="$TRAVIS_BUILD_DIR/bitrix"
fi
download() {
wget http://download.retailcrm.pro/modules/bitrix/bitrix.tar.gz
mkdir $BITRIX_PATH
tar -xf $TRAVIS_BUILD_DIR/bitrix.tar.gz -C $BITRIX_PATH
rm $TRAVIS_BUILD_DIR/bitrix.tar.gz
}
create_db() {
mysqladmin create $DB_BITRIX_NAME --user="$DB_BITRIX_LOGIN" --password="$DB_BITRIX_PASS"
mysql --user="$DB_BITRIX_LOGIN" --password="$DB_BITRIX_PASS" $DB_BITRIX_NAME < $BITRIX_PATH/dump.sql
}
download
create_db

18
tests/phpunit/bootstrap.php → tests/bootstrap.php Normal file → Executable file
View File

@ -9,16 +9,16 @@
* @see http://help.retailcrm.ru
*/
if (file_exists(__DIR__ . '/../../.env')) {
$dotenv = Dotenv\Dotenv::create(__DIR__ . '/../../');
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
if (file_exists(__DIR__ . '/../.env')) {
$dotenv = Dotenv\Dotenv::create(__DIR__ . '/../');
$dotenv->load();
}
if (getenv('TRAVIS_BUILD_DIR')) {
$_SERVER['DOCUMENT_ROOT'] = getenv('TRAVIS_BUILD_DIR') . '/bitrix';
} else {
$_SERVER['DOCUMENT_ROOT'] = getenv('BITRIX_PATH');
}
$_SERVER['DOCUMENT_ROOT'] = getenv('BITRIX_PATH') ? getenv('BITRIX_PATH') : '/var/www/html';
define('NOT_CHECK_PERMISSIONS', true);
define('NO_AGENT_CHECK', true);
@ -28,6 +28,8 @@ require($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.
global $USER;
$USER->Authorize(1);
if (!CModule::IncludeModule('intaro.retailcrm')) {
if (!IsModuleInstalled('intaro.retailcrm')) {
RegisterModule('intaro.retailcrm');
}
CModule::IncludeModule('intaro.retailcrm');