diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c7e845b..3dd5f73 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -10,14 +10,16 @@ jobs: steps: - uses: actions/checkout@v1 - name: Build the docker-compose stack - run: docker-compose -f docker-compose.yml -p yii2-import build + run: docker build -t yii2-import:latest -f ./tests/docker/Dockerfile ./tests/docker - name: Install composer packages - run: docker run --rm --volume $PWD:/app yii2-import_application composer install + run: docker run --rm --volume $PWD:/app yii2-import:latest composer install - name: Run docker containers run: docker-compose -f docker-compose.yml up -d - name: Check running containers - run: docker ps -a + run: docker-compose ps - name: Check logs - run: docker logs yii2-import + run: docker-compose logs - name: Run test suite run: docker-compose exec -T application composer test + - name: Stop docker containers + run: docker-compose -f docker-compose.yml down diff --git a/LICENSE b/LICENSE index d5cf4db..da018da 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 bankrot +Copyright (c) 2020 eLFuvo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 9e48cef..4c8fcec 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ to the "require" section of your `composer.json` file. Configure --------- -Configure desired storage option for the import result and the available import adapters +Configure desired storage option for the import result and available import adapters ```php // in common app config @@ -158,7 +158,7 @@ Also, the validation rules set automatically type of conversion of import data t Important! Import file must have column(s) with unique (identity) values for updating existing models. -Yii2 queue component must be configured for executing ImportJob. +Yii2 [queue](https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/README.md) component must be configured for executing ImportJob. Screenshots ------------ diff --git a/composer.json b/composer.json index 60f0b71..b0c879b 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "autoload": { "psr-4": { "elfuvo\\import\\": "src", - "elfuvo\\import\\app\\": "tests/app" + "elfuvo\\import\\tests\\app\\": "tests/app" } }, "require-dev": { diff --git a/src/ImportService.php b/src/ImportService.php index a289103..bb15ff6 100644 --- a/src/ImportService.php +++ b/src/ImportService.php @@ -193,6 +193,7 @@ public function importBatch(): bool /** @var Model|ActiveRecord $model */ $model = clone $this->model; // some behaviors can be detached for the original model + // so detach its for cloned model foreach ($model->getBehaviors() as $behavior => $config) { if (!in_array($behavior, $behaviors)) { $model->detachBehavior($behavior); diff --git a/tests/app/config/common.php b/tests/app/config/common.php index 92221a6..d215ad7 100644 --- a/tests/app/config/common.php +++ b/tests/app/config/common.php @@ -8,7 +8,7 @@ return [ 'id' => 'tests', - 'controllerNamespace' => 'elfuvo\\import\\app\\controllers', + 'controllerNamespace' => 'elfuvo\\import\\tests\\app\\controllers', 'viewPath' => '@app/views', 'defaultRoute' => 'default/upload-file-import', 'name' => 'Import wizard', @@ -34,8 +34,8 @@ \elfuvo\import\adapter\AdapterImportCsv::class, ] ], - yii\web\Request::class => [ - 'class' => yii\web\Request::class, + \yii\web\Request::class => [ + 'class' => \yii\web\Request::class, 'enableCookieValidation' => false, 'enableCsrfValidation' => false, ] @@ -43,14 +43,8 @@ ], 'modules' => [], 'components' => [ - 'redis' => [ - 'class' => 'yii\redis\Connection', - 'hostname' => 'localhost', - 'port' => 6379, - 'database' => 0, - ], 'cache' => [ - 'class' => yii\caching\FileCache::class, + 'class' => \yii\caching\FileCache::class, 'keyPrefix' => 'import-wizard', ], 'queue' => [ diff --git a/tests/app/config/test.php b/tests/app/config/test.php index d1cbc06..98b83ee 100644 --- a/tests/app/config/test.php +++ b/tests/app/config/test.php @@ -9,7 +9,7 @@ return \yii\helpers\ArrayHelper::merge(require('common.php'), [ 'id' => 'tests', - 'controllerNamespace' => 'elfuvo\\import\\app\\controllers', + 'controllerNamespace' => 'elfuvo\\import\\tests\\app\\controllers', 'viewPath' => '@app/views', 'defaultRoute' => 'default/upload-file-import', 'name' => 'Import wizard', diff --git a/tests/app/controllers/DefaultController.php b/tests/app/controllers/DefaultController.php index d7919c3..c8d7bbe 100644 --- a/tests/app/controllers/DefaultController.php +++ b/tests/app/controllers/DefaultController.php @@ -6,12 +6,12 @@ * Time: 21:33 */ -namespace elfuvo\import\app\controllers; +namespace elfuvo\import\tests\app\controllers; use elfuvo\import\actions\ProgressAction; use elfuvo\import\actions\SetupAction; use elfuvo\import\actions\UploadFileAction; -use elfuvo\import\app\models\Review; +use elfuvo\import\tests\app\models\Review; use yii\web\Controller; use yii\web\ErrorAction; diff --git a/tests/app/models/Review.php b/tests/app/models/Review.php index 78dffa4..56c10fc 100644 --- a/tests/app/models/Review.php +++ b/tests/app/models/Review.php @@ -6,7 +6,7 @@ * Time: 21:33 */ -namespace elfuvo\import\app\models; +namespace elfuvo\import\tests\app\models; use Yii; use yii\base\Model; @@ -15,7 +15,7 @@ /** * * Class Review - * @package elfuvo\import\app\models + * @package elfuvo\import\tests\app\models */ class Review extends Model { @@ -105,7 +105,7 @@ public function rules() * @param null $attributeNames * @return bool */ - public function save($runValidation = true, $attributeNames = null) + public function save($runValidation = true, $attributeNames = null): bool { if ($this->validate()) { self::getList(); diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index bd9eda2..e1fa9f0 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -53,22 +53,8 @@ memory_limit=-1\n\ ENV COMPOSER_ALLOW_SUPERUSER 1 ENV COMPOSER_HOME /tmp -ENV COMPOSER_VERSION 1.9.3 -RUN set -eux; \ - curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://raw.githubusercontent.com/composer/getcomposer.org/cb19f2aa3aeaa2006c0cd69a7ef011eb31463067/web/installer; \ - php -r " \ - \$signature = '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5'; \ - \$hash = hash('sha384', file_get_contents('/tmp/installer.php')); \ - if (!hash_equals(\$signature, \$hash)) { \ - unlink('/tmp/installer.php'); \ - echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ - exit(1); \ - }"; \ - php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION}; \ - composer --ansi --version --no-interaction; \ - rm -f /tmp/installer.php; \ - find /tmp -type d -exec chmod -v 1777 {} + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer COPY docker-entrypoint.sh /docker-entrypoint.sh