From 3c0eb8da84354dbd4d1a4e2f6203d160b76ed1f0 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 24 Jul 2025 16:01:25 +0300 Subject: [PATCH 1/3] Adapt to Yii Data changes + Improve docker --- Makefile | 49 ++++++++++++++----- docker/.gitignore | 1 + Dockerfile => docker/Dockerfile | 44 ++++++++++------- .../docker-compose.yml | 13 +++-- docker/oracle/init.sql | 1 + src/FilterHandler.php | 8 +-- ...ilterHandler.php => AndXFilterHandler.php} | 13 +++-- ...FilterHandler.php => OrXFilterHandler.php} | 13 +++-- tests/Base/BaseQueryDataReaderTestCase.php | 40 +++++++-------- ...ase.php => BaseReaderWithAndXTestCase.php} | 2 +- ...Case.php => BaseReaderWithOrXTestCase.php} | 2 +- ...WithAnyTest.php => ReaderWithAndXTest.php} | 4 +- ...rWithAllTest.php => ReaderWithOrXTest.php} | 4 +- ...WithAnyTest.php => ReaderWithAndXTest.php} | 4 +- ...rWithAllTest.php => ReaderWithOrXTest.php} | 4 +- tests/Oracle/QueryDataReaderTest.php | 12 ++--- ...WithAnyTest.php => ReaderWithAndXTest.php} | 4 +- ...rWithAllTest.php => ReaderWithOrXTest.php} | 4 +- ...WithAnyTest.php => ReaderWithAndXTest.php} | 4 +- ...rWithAllTest.php => ReaderWithOrXTest.php} | 4 +- tests/Sqlite/QueryDataReaderTest.php | 12 ++--- ...WithAnyTest.php => ReaderWithAndXTest.php} | 4 +- ...rWithAllTest.php => ReaderWithOrXTest.php} | 4 +- 23 files changed, 144 insertions(+), 106 deletions(-) create mode 100644 docker/.gitignore rename Dockerfile => docker/Dockerfile (63%) rename docker-compose.yml => docker/docker-compose.yml (88%) create mode 100644 docker/oracle/init.sql rename src/FilterHandler/{AllFilterHandler.php => AndXFilterHandler.php} (70%) rename src/FilterHandler/{AnyFilterHandler.php => OrXFilterHandler.php} (70%) rename tests/Base/Reader/ReaderWithFilter/{BaseReaderWithAllTestCase.php => BaseReaderWithAndXTestCase.php} (55%) rename tests/Base/Reader/ReaderWithFilter/{BaseReaderWithAnyTestCase.php => BaseReaderWithOrXTestCase.php} (56%) rename tests/Mssql/ReaderWithHandler/{ReaderWithAnyTest.php => ReaderWithAndXTest.php} (73%) rename tests/Mssql/ReaderWithHandler/{ReaderWithAllTest.php => ReaderWithOrXTest.php} (73%) rename tests/Mysql/ReaderWithFilter/{ReaderWithAnyTest.php => ReaderWithAndXTest.php} (72%) rename tests/Mysql/ReaderWithFilter/{ReaderWithAllTest.php => ReaderWithOrXTest.php} (73%) rename tests/Oracle/ReaderWithHandler/{ReaderWithAnyTest.php => ReaderWithAndXTest.php} (73%) rename tests/Oracle/ReaderWithHandler/{ReaderWithAllTest.php => ReaderWithOrXTest.php} (73%) rename tests/Pgsql/ReaderWithFilter/{ReaderWithAnyTest.php => ReaderWithAndXTest.php} (72%) rename tests/Pgsql/ReaderWithFilter/{ReaderWithAllTest.php => ReaderWithOrXTest.php} (73%) rename tests/Sqlite/ReaderWithFilter/{ReaderWithAnyTest.php => ReaderWithAndXTest.php} (73%) rename tests/Sqlite/ReaderWithFilter/{ReaderWithAllTest.php => ReaderWithOrXTest.php} (73%) diff --git a/Makefile b/Makefile index 50c4eb6..0e2be7c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,29 @@ -run: - docker compose run --rm --entrypoint $(CMD) php +.PHONY: help +help: ## Show the list of available commands with description. + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) +.DEFAULT_GOAL := help + +build: ## Build services + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml build +up: ## Start services + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d --remove-orphans +build-up: # Build and start services + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d --remove-orphans --build +ps: ## List running services + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml ps +stop: ## Stop running services + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml stop +down: ## Stop running services and remove all services (not defined services, containers, networks, volumes, images) + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml down \ + --remove-orphans \ + --volumes \ + --rmi all + +run: ## Run arbitrary command + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ + --rm \ + --entrypoint $(CMD) \ + php test-all: test-sqlite \ test-mysql \ @@ -11,19 +35,19 @@ test-mysql: testsuite-Mysql test-pgsql: testsuite-Pgsql test-mssql: testsuite-Mssql test-oracle: - docker compose run \ + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ - --entrypoint 'bash -c -l "vendor/bin/phpunit --testsuite Oracle"' \ + --entrypoint "bash -c -l 'vendor/bin/phpunit --testsuite Oracle $(RUN_ARGS)'" \ php testsuite-%: - docker compose run \ + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ - --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@)" \ + --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@) $(RUN_ARGS)" \ php -static-analysis: CMD="vendor/bin/psalm --no-cache" -static-analysis: run +psalm: CMD="vendor/bin/psalm --no-cache" ## Run static analysis using Psalm +psalm: run mutation: CMD="\ vendor/bin/roave-infection-static-analysis-plugin \ @@ -31,11 +55,14 @@ vendor/bin/roave-infection-static-analysis-plugin \ --min-msi=0 \ --min-covered-msi=100 \ --ignore-msi-with-no-mutations \ ---only-covered" +--only-covered" ## Run mutation tests using Infection mutation: run -composer-require-checker: CMD="vendor/bin/composer-require-checker" +composer-require-checker: CMD="vendor/bin/composer-require-checker" ## Check dependencies using Composer Require Checker composer-require-checker: run -shell: CMD="bash" +rector: CMD="vendor/bin/rector" ## Check code style using Rector +rector: run + +shell: CMD="bash" ## Open interactive shell shell: run diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 0000000..f2bec73 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1 @@ +/docker-compose.override.yml diff --git a/Dockerfile b/docker/Dockerfile similarity index 63% rename from Dockerfile rename to docker/Dockerfile index bf0a953..08e87ac 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,5 @@ FROM composer/composer:latest-bin AS composer + FROM php:8.3-cli # System packages @@ -34,17 +35,24 @@ RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ && rm -rf /var/lib/apt/lists/* # Oracle dependencies - -RUN cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-basic-linux.x64-23.5.0.24.07.zip -O -RUN cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sdk-linux.x64-23.5.0.24.07.zip -O -RUN cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sqlplus-linux.x64-23.5.0.24.07.zip -O - -RUN unzip /tmp/instantclient-basic-linux.x64-23.5.0.24.07.zip -d /usr/local/ -RUN unzip -o /tmp/instantclient-sdk-linux.x64-23.5.0.24.07.zip -d /usr/local/ -RUN unzip -o /tmp/instantclient-sqlplus-linux.x64-23.5.0.24.07.zip -d /usr/local/ - -RUN ln -s /usr/local/instantclient_23_5 /usr/local/instantclient -# Fixes error "libnnz19.so: cannot open shared object file: No such file or directory" +ARG TARGETARCH +RUN if [ "$TARGETARCH" = "arm64" ] ; then \ + cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2370000/instantclient-basic-linux.arm64-23.7.0.25.01.zip -O \ + && curl -L https://download.oracle.com/otn_software/linux/instantclient/2370000/instantclient-sdk-linux.arm64-23.7.0.25.01.zip -O \ + && curl -L https://download.oracle.com/otn_software/linux/instantclient/2370000/instantclient-sqlplus-linux.arm64-23.7.0.25.01.zip -O \ + && unzip -o /tmp/instantclient-basic-linux.arm64-23.7.0.25.01.zip -d /usr/local/ \ + && unzip -o /tmp/instantclient-sdk-linux.arm64-23.7.0.25.01.zip -d /usr/local/ \ + && unzip -o /tmp/instantclient-sqlplus-linux.arm64-23.7.0.25.01.zip -d /usr/local/ \ + && ln -s /usr/local/instantclient_23_7 /usr/local/instantclient; \ + elif [ "$TARGETARCH" = "amd64" ]; then \ + cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-basic-linux.x64-23.5.0.24.07.zip -O \ + && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sdk-linux.x64-23.5.0.24.07.zip -O \ + && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sqlplus-linux.x64-23.5.0.24.07.zip -O \ + && unzip /tmp/instantclient-basic-linux.x64-23.5.0.24.07.zip -d /usr/local/ \ + && unzip -o /tmp/instantclient-sdk-linux.x64-23.5.0.24.07.zip -d /usr/local/ \ + && unzip -o /tmp/instantclient-sqlplus-linux.x64-23.5.0.24.07.zip -d /usr/local/ \ + && ln -s /usr/local/instantclient_23_5 /usr/local/instantclient; \ + fi RUN ln -s /usr/local/instantclient/lib* /usr/lib RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus @@ -59,18 +67,18 @@ RUN docker-php-ext-install \ # For Psalm, to make use of JIT for a 20%+ performance boost. opcache -RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8 -RUN echo "extension=oci8.so" > /usr/local/etc/php/conf.d/php-oci8.ini - -RUN echo 'instantclient,/usr/local/instantclient' | pecl install pdo_oci -RUN echo "extension=pdo_oci.so" > /usr/local/etc/php/conf.d/php-pdo-oci.ini - RUN pecl install sqlsrv RUN printf "; priority=20\nextension=sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-sqlsrv.ini RUN pecl install pdo_sqlsrv RUN printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-pdo-sqlsrv.ini +RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8 +RUN echo "extension=oci8.so" > /usr/local/etc/php/conf.d/php-oci8.ini + +RUN echo 'instantclient,/usr/local/instantclient' | pecl install pdo_oci +RUN echo "extension=pdo_oci.so" > /usr/local/etc/php/conf.d/php-pdo-oci.ini + # For code coverage (mutation testing) RUN pecl install pcov && docker-php-ext-enable pcov @@ -85,4 +93,4 @@ WORKDIR /code # PHP packages -RUN composer install +RUN COMPOSER_ALLOW_SUPERUSER=1 composer install diff --git a/docker-compose.yml b/docker/docker-compose.yml similarity index 88% rename from docker-compose.yml rename to docker/docker-compose.yml index 9ebdbf1..59b4f1a 100644 --- a/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,10 +1,12 @@ services: php: - build: . + build: + context: ./.. + dockerfile: ./docker/Dockerfile volumes: - - ./src:/code/src - - ./tests:/code/tests - - ./phpunit.xml.dist:/code/phpunit.xml.dist + - ./../src:/code/src + - ./../tests:/code/tests + - ./../phpunit.xml.dist:/code/phpunit.xml.dist command: tail -F anything depends_on: mysql: @@ -67,10 +69,11 @@ services: start_period: 10s oracle: build: - context: docker/oracle + context: oracle ports: - "1521:1521" volumes: + - ./oracle/init.sql:/docker-entrypoint-initdb.d/init.sql - oracle-data:/opt/oracle/oradata environment: ORACLE_PASSWORD: sys_user_password diff --git a/docker/oracle/init.sql b/docker/oracle/init.sql new file mode 100644 index 0000000..6205396 --- /dev/null +++ b/docker/oracle/init.sql @@ -0,0 +1 @@ +ALTER USER system DEFAULT TABLESPACE USERS; diff --git a/src/FilterHandler.php b/src/FilterHandler.php index e6ae03b..9f6d1d8 100644 --- a/src/FilterHandler.php +++ b/src/FilterHandler.php @@ -5,8 +5,8 @@ namespace Yiisoft\Data\Db; use LogicException; -use Yiisoft\Data\Db\FilterHandler\AllFilterHandler; -use Yiisoft\Data\Db\FilterHandler\AnyFilterHandler; +use Yiisoft\Data\Db\FilterHandler\AndXFilterHandler; +use Yiisoft\Data\Db\FilterHandler\OrXFilterHandler; use Yiisoft\Data\Db\FilterHandler\BetweenFilterHandler; use Yiisoft\Data\Db\FilterHandler\Criteria; use Yiisoft\Data\Db\FilterHandler\Context; @@ -48,8 +48,8 @@ public function __construct( ) { if (empty($handlers)) { $handlers = [ - new AllFilterHandler(), - new AnyFilterHandler(), + new AndXFilterHandler(), + new OrXFilterHandler(), new EqualsFilterHandler(), new GreaterThanFilterHandler(), new GreaterThanOrEqualFilterHandler(), diff --git a/src/FilterHandler/AllFilterHandler.php b/src/FilterHandler/AndXFilterHandler.php similarity index 70% rename from src/FilterHandler/AllFilterHandler.php rename to src/FilterHandler/AndXFilterHandler.php index 357804c..a124730 100644 --- a/src/FilterHandler/AllFilterHandler.php +++ b/src/FilterHandler/AndXFilterHandler.php @@ -4,29 +4,28 @@ namespace Yiisoft\Data\Db\FilterHandler; -use Yiisoft\Data\Reader\Filter\All; +use Yiisoft\Data\Reader\Filter\AndX; use Yiisoft\Data\Reader\FilterInterface; -final class AllFilterHandler implements QueryFilterHandlerInterface +final class AndXFilterHandler implements QueryFilterHandlerInterface { public function getFilterClass(): string { - return All::class; + return AndX::class; } public function getCriteria(FilterInterface $filter, Context $context): ?Criteria { - /** @var All $filter */ + /** @var AndX $filter */ - $filters = $filter->getFilters(); - if (empty($filters)) { + if (empty($filter->filters)) { return null; } $condition = ['AND']; $params = []; - foreach ($filters as $subFilter) { + foreach ($filter->filters as $subFilter) { $criteria = $context->handleFilter($subFilter); if ($criteria !== null) { $condition[] = $criteria->condition; diff --git a/src/FilterHandler/AnyFilterHandler.php b/src/FilterHandler/OrXFilterHandler.php similarity index 70% rename from src/FilterHandler/AnyFilterHandler.php rename to src/FilterHandler/OrXFilterHandler.php index 1a93bf7..f3eef47 100644 --- a/src/FilterHandler/AnyFilterHandler.php +++ b/src/FilterHandler/OrXFilterHandler.php @@ -4,29 +4,28 @@ namespace Yiisoft\Data\Db\FilterHandler; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\FilterInterface; -final class AnyFilterHandler implements QueryFilterHandlerInterface +final class OrXFilterHandler implements QueryFilterHandlerInterface { public function getFilterClass(): string { - return Any::class; + return OrX::class; } public function getCriteria(FilterInterface $filter, Context $context): ?Criteria { - /** @var Any $filter */ + /** @var OrX $filter */ - $filters = $filter->getFilters(); - if (empty($filters)) { + if (empty($filter->filters)) { return null; } $condition = ['OR']; $params = []; - foreach ($filters as $subFilter) { + foreach ($filter->filters as $subFilter) { $criteria = $context->handleFilter($subFilter); if ($criteria !== null) { $condition[] = $criteria->condition; diff --git a/tests/Base/BaseQueryDataReaderTestCase.php b/tests/Base/BaseQueryDataReaderTestCase.php index b3f9c9b..f5457ff 100644 --- a/tests/Base/BaseQueryDataReaderTestCase.php +++ b/tests/Base/BaseQueryDataReaderTestCase.php @@ -10,8 +10,7 @@ use Yiisoft\Data\Db\QueryDataReader; use Yiisoft\Data\Db\Tests\Support\CustomerDataReader; use Yiisoft\Data\Db\Tests\Support\CustomerDTO; -use Yiisoft\Data\Reader\Filter\All; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\AndX; use Yiisoft\Data\Reader\Filter\Between; use Yiisoft\Data\Reader\Filter\Equals; use Yiisoft\Data\Reader\Filter\EqualsNull; @@ -22,6 +21,7 @@ use Yiisoft\Data\Reader\Filter\LessThanOrEqual; use Yiisoft\Data\Reader\Filter\Like; use Yiisoft\Data\Reader\Filter\Not; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\FilterInterface; use Yiisoft\Data\Reader\Sort; use Yiisoft\Db\Expression\Expression; @@ -264,12 +264,12 @@ public static function dataFilterSql(): array "[[column]] NOT LIKE '%foo%'", ], // Group - 'all, any' => [ - new All( + 'and, or' => [ + new AndX( new EqualsNull('null_column'), new Equals('equals', 10), new Between('between', 10, 20), - new Any( + new OrX( new Equals('id', 8), new Like('name', 'foo') ) @@ -279,12 +279,12 @@ public static function dataFilterSql(): array '([[between]] BETWEEN 10 AND 20) AND ' . "(([[id]] = 8) OR ([[name]] LIKE '%foo%'))", ], - 'any, all' => [ - new Any( + 'or, and' => [ + new OrX( new GreaterThan('greater_than', 15), new LessThanOrEqual('less_than_or_equal', 10), new Not(new Equals('not_equals', 'test')), - new All( + new AndX( new Equals('id', 8), new Like('name', 'bar') ) @@ -294,40 +294,40 @@ public static function dataFilterSql(): array "([[not_equals]] != 'test') OR " . "(([[id]] = 8) AND ([[name]] LIKE '%bar%'))", ], - 'all, any 2' => [ - new All( + 'and, or 2' => [ + new AndX( new GreaterThan('id', 88), - new Any( + new OrX( new Equals('state', 2), new Like('name', 'eva'), ) ), "([[id]] > 88) AND (([[state]] = 2) OR ([[name]] LIKE '%eva%'))", ], - 'any, all 2' => [ - new Any( + 'or, and 2' => [ + new OrX( new GreaterThan('id', 88), - new All( + new AndX( new Equals('state', 2), new Like('name', 'eva'), ) ), "([[id]] > 88) OR (([[state]] = 2) AND ([[name]] LIKE '%eva%'))", ], - 'any, any' => [ - new Any( + 'or, or' => [ + new OrX( new GreaterThan('id', 88), - new Any( + new OrX( new Equals('state', 2), new Like('name', 'eva'), ) ), "([[id]] > 88) OR (([[state]] = 2) OR ([[name]] LIKE '%eva%'))", ], - 'all, all' => [ - new All( + 'and, and' => [ + new AndX( new GreaterThan('id', 88), - new All( + new AndX( new Equals('state', 2), new Like('name', 'eva'), ) diff --git a/tests/Base/Reader/ReaderWithFilter/BaseReaderWithAllTestCase.php b/tests/Base/Reader/ReaderWithFilter/BaseReaderWithAndXTestCase.php similarity index 55% rename from tests/Base/Reader/ReaderWithFilter/BaseReaderWithAllTestCase.php rename to tests/Base/Reader/ReaderWithFilter/BaseReaderWithAndXTestCase.php index 7aa5200..4ee82f0 100644 --- a/tests/Base/Reader/ReaderWithFilter/BaseReaderWithAllTestCase.php +++ b/tests/Base/Reader/ReaderWithFilter/BaseReaderWithAndXTestCase.php @@ -6,7 +6,7 @@ use Yiisoft\Data\Db\Tests\Base\DataTrait; -abstract class BaseReaderWithAllTestCase extends \Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithAllTestCase +abstract class BaseReaderWithAndXTestCase extends \Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithAndXTestCase { use DataTrait; } diff --git a/tests/Base/Reader/ReaderWithFilter/BaseReaderWithAnyTestCase.php b/tests/Base/Reader/ReaderWithFilter/BaseReaderWithOrXTestCase.php similarity index 56% rename from tests/Base/Reader/ReaderWithFilter/BaseReaderWithAnyTestCase.php rename to tests/Base/Reader/ReaderWithFilter/BaseReaderWithOrXTestCase.php index 332cc20..2bac74d 100644 --- a/tests/Base/Reader/ReaderWithFilter/BaseReaderWithAnyTestCase.php +++ b/tests/Base/Reader/ReaderWithFilter/BaseReaderWithOrXTestCase.php @@ -6,7 +6,7 @@ use Yiisoft\Data\Db\Tests\Base\DataTrait; -abstract class BaseReaderWithAnyTestCase extends \Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithAnyTestCase +abstract class BaseReaderWithOrXTestCase extends \Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithOrXTestCase { use DataTrait; } diff --git a/tests/Mssql/ReaderWithHandler/ReaderWithAnyTest.php b/tests/Mssql/ReaderWithHandler/ReaderWithAndXTest.php similarity index 73% rename from tests/Mssql/ReaderWithHandler/ReaderWithAnyTest.php rename to tests/Mssql/ReaderWithHandler/ReaderWithAndXTest.php index cfa8c4c..ce95b28 100644 --- a/tests/Mssql/ReaderWithHandler/ReaderWithAnyTest.php +++ b/tests/Mssql/ReaderWithHandler/ReaderWithAndXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Mssql\ReaderWithHandler; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAnyTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAndXTestCase; use Yiisoft\Data\Db\Tests\Mssql\DatabaseTrait; -final class ReaderWithAnyTest extends BaseReaderWithAnyTestCase +final class ReaderWithAndXTest extends BaseReaderWithAndXTestCase { use DatabaseTrait; } diff --git a/tests/Mssql/ReaderWithHandler/ReaderWithAllTest.php b/tests/Mssql/ReaderWithHandler/ReaderWithOrXTest.php similarity index 73% rename from tests/Mssql/ReaderWithHandler/ReaderWithAllTest.php rename to tests/Mssql/ReaderWithHandler/ReaderWithOrXTest.php index 0b83314..8d957c7 100644 --- a/tests/Mssql/ReaderWithHandler/ReaderWithAllTest.php +++ b/tests/Mssql/ReaderWithHandler/ReaderWithOrXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Mssql\ReaderWithHandler; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAllTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithOrXTestCase; use Yiisoft\Data\Db\Tests\Mssql\DatabaseTrait; -final class ReaderWithAllTest extends BaseReaderWithAllTestCase +final class ReaderWithOrXTest extends BaseReaderWithOrXTestCase { use DatabaseTrait; } diff --git a/tests/Mysql/ReaderWithFilter/ReaderWithAnyTest.php b/tests/Mysql/ReaderWithFilter/ReaderWithAndXTest.php similarity index 72% rename from tests/Mysql/ReaderWithFilter/ReaderWithAnyTest.php rename to tests/Mysql/ReaderWithFilter/ReaderWithAndXTest.php index 628134d..f36e70b 100644 --- a/tests/Mysql/ReaderWithFilter/ReaderWithAnyTest.php +++ b/tests/Mysql/ReaderWithFilter/ReaderWithAndXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Mysql\ReaderWithFilter; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAnyTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAndXTestCase; use Yiisoft\Data\Db\Tests\Mysql\DatabaseTrait; -final class ReaderWithAnyTest extends BaseReaderWithAnyTestCase +final class ReaderWithAndXTest extends BaseReaderWithAndXTestCase { use DatabaseTrait; } diff --git a/tests/Mysql/ReaderWithFilter/ReaderWithAllTest.php b/tests/Mysql/ReaderWithFilter/ReaderWithOrXTest.php similarity index 73% rename from tests/Mysql/ReaderWithFilter/ReaderWithAllTest.php rename to tests/Mysql/ReaderWithFilter/ReaderWithOrXTest.php index ed02a6f..3414ae0 100644 --- a/tests/Mysql/ReaderWithFilter/ReaderWithAllTest.php +++ b/tests/Mysql/ReaderWithFilter/ReaderWithOrXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Mysql\ReaderWithFilter; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAllTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithOrXTestCase; use Yiisoft\Data\Db\Tests\Mysql\DatabaseTrait; -final class ReaderWithAllTest extends BaseReaderWithAllTestCase +final class ReaderWithOrXTest extends BaseReaderWithOrXTestCase { use DatabaseTrait; } diff --git a/tests/Oracle/QueryDataReaderTest.php b/tests/Oracle/QueryDataReaderTest.php index 29b5197..8049672 100644 --- a/tests/Oracle/QueryDataReaderTest.php +++ b/tests/Oracle/QueryDataReaderTest.php @@ -38,18 +38,18 @@ public static function dataFilterSql(): array $replacementMap = [ 'like' => "[[column]] LIKE '%foo%' ESCAPE '!'", 'not like' => "[[column]] NOT LIKE '%foo%' ESCAPE '!'", - 'all, any' => '([[null_column]] IS NULL) AND ' . + 'and, or' => '([[null_column]] IS NULL) AND ' . '([[equals]] = 10) AND ' . '([[between]] BETWEEN 10 AND 20) AND ' . "(([[id]] = 8) OR ([[name]] LIKE '%foo%' ESCAPE '!'))", - 'any, all' => '([[greater_than]] > 15) OR ' . + 'or, and' => '([[greater_than]] > 15) OR ' . '([[less_than_or_equal]] <= 10) OR ' . "([[not_equals]] != 'test') OR " . "(([[id]] = 8) AND ([[name]] LIKE '%bar%' ESCAPE '!'))", - 'all, any 2' => "([[id]] > 88) AND (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '!'))", - 'any, all 2' => "([[id]] > 88) OR (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '!'))", - 'any, any' => "([[id]] > 88) OR (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '!'))", - 'all, all' => "([[id]] > 88) AND (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '!'))", + 'and, or 2' => "([[id]] > 88) AND (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '!'))", + 'or, and 2' => "([[id]] > 88) OR (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '!'))", + 'or, or' => "([[id]] > 88) OR (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '!'))", + 'and, and' => "([[id]] > 88) AND (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '!'))", ]; foreach ($replacementMap as $key => $value) { $data[$key][1] = $value; diff --git a/tests/Oracle/ReaderWithHandler/ReaderWithAnyTest.php b/tests/Oracle/ReaderWithHandler/ReaderWithAndXTest.php similarity index 73% rename from tests/Oracle/ReaderWithHandler/ReaderWithAnyTest.php rename to tests/Oracle/ReaderWithHandler/ReaderWithAndXTest.php index ac377fe..c803f23 100644 --- a/tests/Oracle/ReaderWithHandler/ReaderWithAnyTest.php +++ b/tests/Oracle/ReaderWithHandler/ReaderWithAndXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Oracle\ReaderWithHandler; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAnyTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAndXTestCase; use Yiisoft\Data\Db\Tests\Oracle\DatabaseTrait; -final class ReaderWithAnyTest extends BaseReaderWithAnyTestCase +final class ReaderWithAndXTest extends BaseReaderWithAndXTestCase { use DatabaseTrait; } diff --git a/tests/Oracle/ReaderWithHandler/ReaderWithAllTest.php b/tests/Oracle/ReaderWithHandler/ReaderWithOrXTest.php similarity index 73% rename from tests/Oracle/ReaderWithHandler/ReaderWithAllTest.php rename to tests/Oracle/ReaderWithHandler/ReaderWithOrXTest.php index dd63068..edfeb6e 100644 --- a/tests/Oracle/ReaderWithHandler/ReaderWithAllTest.php +++ b/tests/Oracle/ReaderWithHandler/ReaderWithOrXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Oracle\ReaderWithHandler; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAllTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithOrXTestCase; use Yiisoft\Data\Db\Tests\Oracle\DatabaseTrait; -final class ReaderWithAllTest extends BaseReaderWithAllTestCase +final class ReaderWithOrXTest extends BaseReaderWithOrXTestCase { use DatabaseTrait; } diff --git a/tests/Pgsql/ReaderWithFilter/ReaderWithAnyTest.php b/tests/Pgsql/ReaderWithFilter/ReaderWithAndXTest.php similarity index 72% rename from tests/Pgsql/ReaderWithFilter/ReaderWithAnyTest.php rename to tests/Pgsql/ReaderWithFilter/ReaderWithAndXTest.php index 5849321..78ce4fc 100644 --- a/tests/Pgsql/ReaderWithFilter/ReaderWithAnyTest.php +++ b/tests/Pgsql/ReaderWithFilter/ReaderWithAndXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Pgsql\ReaderWithFilter; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAnyTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAndXTestCase; use Yiisoft\Data\Db\Tests\Pgsql\DatabaseTrait; -final class ReaderWithAnyTest extends BaseReaderWithAnyTestCase +final class ReaderWithAndXTest extends BaseReaderWithAndXTestCase { use DatabaseTrait; } diff --git a/tests/Pgsql/ReaderWithFilter/ReaderWithAllTest.php b/tests/Pgsql/ReaderWithFilter/ReaderWithOrXTest.php similarity index 73% rename from tests/Pgsql/ReaderWithFilter/ReaderWithAllTest.php rename to tests/Pgsql/ReaderWithFilter/ReaderWithOrXTest.php index 46176d7..40cdbaa 100644 --- a/tests/Pgsql/ReaderWithFilter/ReaderWithAllTest.php +++ b/tests/Pgsql/ReaderWithFilter/ReaderWithOrXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Pgsql\ReaderWithFilter; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAllTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithOrXTestCase; use Yiisoft\Data\Db\Tests\Pgsql\DatabaseTrait; -final class ReaderWithAllTest extends BaseReaderWithAllTestCase +final class ReaderWithOrXTest extends BaseReaderWithOrXTestCase { use DatabaseTrait; } diff --git a/tests/Sqlite/QueryDataReaderTest.php b/tests/Sqlite/QueryDataReaderTest.php index 3a2e08a..cc7319c 100644 --- a/tests/Sqlite/QueryDataReaderTest.php +++ b/tests/Sqlite/QueryDataReaderTest.php @@ -25,18 +25,18 @@ public static function dataFilterSql(): array $replacementMap = [ 'like' => "[[column]] LIKE '%foo%' ESCAPE '\'", 'not like' => "[[column]] NOT LIKE '%foo%' ESCAPE '\'", - 'all, any' => '([[null_column]] IS NULL) AND ' . + 'and, or' => '([[null_column]] IS NULL) AND ' . '([[equals]] = 10) AND ' . '([[between]] BETWEEN 10 AND 20) AND ' . "(([[id]] = 8) OR ([[name]] LIKE '%foo%' ESCAPE '\'))", - 'any, all' => '([[greater_than]] > 15) OR ' . + 'or, and' => '([[greater_than]] > 15) OR ' . '([[less_than_or_equal]] <= 10) OR ' . "([[not_equals]] != 'test') OR " . "(([[id]] = 8) AND ([[name]] LIKE '%bar%' ESCAPE '\'))", - 'all, any 2' => "([[id]] > 88) AND (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '\'))", - 'any, all 2' => "([[id]] > 88) OR (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '\'))", - 'any, any' => "([[id]] > 88) OR (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '\'))", - 'all, all' => "([[id]] > 88) AND (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '\'))", + 'and, or 2' => "([[id]] > 88) AND (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '\'))", + 'or, and 2' => "([[id]] > 88) OR (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '\'))", + 'or, or' => "([[id]] > 88) OR (([[state]] = 2) OR ([[name]] LIKE '%eva%' ESCAPE '\'))", + 'and, and' => "([[id]] > 88) AND (([[state]] = 2) AND ([[name]] LIKE '%eva%' ESCAPE '\'))", ]; foreach ($replacementMap as $key => $value) { $data[$key][1] = $value; diff --git a/tests/Sqlite/ReaderWithFilter/ReaderWithAnyTest.php b/tests/Sqlite/ReaderWithFilter/ReaderWithAndXTest.php similarity index 73% rename from tests/Sqlite/ReaderWithFilter/ReaderWithAnyTest.php rename to tests/Sqlite/ReaderWithFilter/ReaderWithAndXTest.php index 4c52b74..b4acb67 100644 --- a/tests/Sqlite/ReaderWithFilter/ReaderWithAnyTest.php +++ b/tests/Sqlite/ReaderWithFilter/ReaderWithAndXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Sqlite\ReaderWithFilter; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAnyTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAndXTestCase; use Yiisoft\Data\Db\Tests\Sqlite\DatabaseTrait; -final class ReaderWithAnyTest extends BaseReaderWithAnyTestCase +final class ReaderWithAndXTest extends BaseReaderWithAndXTestCase { use DatabaseTrait; } diff --git a/tests/Sqlite/ReaderWithFilter/ReaderWithAllTest.php b/tests/Sqlite/ReaderWithFilter/ReaderWithOrXTest.php similarity index 73% rename from tests/Sqlite/ReaderWithFilter/ReaderWithAllTest.php rename to tests/Sqlite/ReaderWithFilter/ReaderWithOrXTest.php index c091599..6a58bb6 100644 --- a/tests/Sqlite/ReaderWithFilter/ReaderWithAllTest.php +++ b/tests/Sqlite/ReaderWithFilter/ReaderWithOrXTest.php @@ -4,10 +4,10 @@ namespace Yiisoft\Data\Db\Tests\Sqlite\ReaderWithFilter; -use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithAllTestCase; +use Yiisoft\Data\Db\Tests\Base\Reader\ReaderWithFilter\BaseReaderWithOrXTestCase; use Yiisoft\Data\Db\Tests\Sqlite\DatabaseTrait; -final class ReaderWithAllTest extends BaseReaderWithAllTestCase +final class ReaderWithOrXTest extends BaseReaderWithOrXTestCase { use DatabaseTrait; } From a753ebdb4f0b52813c37f30d1a80e9bf7cde67ba Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 24 Jul 2025 22:35:38 +0300 Subject: [PATCH 2/3] ci --- .github/workflows/composer-require-checker.yml | 2 ++ .github/workflows/mssql.yml | 6 ++++++ .github/workflows/mutation.yml | 2 ++ .github/workflows/mysql.yml | 6 ++++++ .github/workflows/oracle.yml | 6 ++++++ .github/workflows/pgsql.yml | 6 ++++++ .github/workflows/rector.yml | 2 ++ .github/workflows/sqlite.yml | 6 ++++++ .github/workflows/static.yml | 2 ++ 9 files changed, 38 insertions(+) diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 919a073..25e9f02 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -33,3 +33,5 @@ jobs: ['ubuntu-latest'] php: >- ['8.1', '8.2', '8.3', '8.4'] + required-packages: >- + ['data'] diff --git a/.github/workflows/mssql.yml b/.github/workflows/mssql.yml index 943ea13..e4b8ff6 100644 --- a/.github/workflows/mssql.yml +++ b/.github/workflows/mssql.yml @@ -103,6 +103,12 @@ jobs: - name: Install dependencies with composer run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Install Yii Data + uses: yiisoft/actions/install-packages@master + with: + packages: >- + ['data'] + - name: Run tests with phpunit run: vendor/bin/phpunit --testsuite=Mssql --coverage-clover=coverage.xml --colors=always env: diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 1094a31..03c1a77 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -29,5 +29,7 @@ jobs: ['ubuntu-latest'] php: >- ['8.3'] + required-packages: >- + ['data'] secrets: STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 03df2b0..aa7e6c0 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -90,6 +90,12 @@ jobs: - name: Install dependencies with composer run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Install Yii Data + uses: yiisoft/actions/install-packages@master + with: + packages: >- + ['data'] + - name: Run tests with phpunit run: vendor/bin/phpunit --testsuite Mysql --coverage-clover=coverage.xml --colors=always env: diff --git a/.github/workflows/oracle.yml b/.github/workflows/oracle.yml index c449e8d..9ea6407 100644 --- a/.github/workflows/oracle.yml +++ b/.github/workflows/oracle.yml @@ -95,6 +95,12 @@ jobs: - name: Install dependencies with composer run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Install Yii Data + uses: yiisoft/actions/install-packages@master + with: + packages: >- + ['data'] + - name: Run tests with phpunit run: vendor/bin/phpunit --testsuite Oracle --coverage-clover=coverage.xml --colors=always env: diff --git a/.github/workflows/pgsql.yml b/.github/workflows/pgsql.yml index 4836ce2..1ea1157 100644 --- a/.github/workflows/pgsql.yml +++ b/.github/workflows/pgsql.yml @@ -98,6 +98,12 @@ jobs: - name: Install dependencies with composer run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Install Yii Data + uses: yiisoft/actions/install-packages@master + with: + packages: >- + ['data'] + - name: Run tests with phpunit run: vendor/bin/phpunit --testsuite Pgsql --coverage-clover=coverage.xml --colors=always env: diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 5d6931d..c56f3b9 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -22,3 +22,5 @@ jobs: ['ubuntu-latest'] php: >- ['8.4'] + required-packages: >- + ['data'] diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index 8c97475..8fb49fd 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -76,6 +76,12 @@ jobs: - name: Run tests with phpunit with code coverage. run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always --configuration phpunit.xml.dist + - name: Install Yii Data + uses: yiisoft/actions/install-packages@master + with: + packages: >- + ['data'] + - name: Upload coverage to Codecov. if: matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v3 diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 9e12684..ba7b0ff 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -31,3 +31,5 @@ jobs: ['ubuntu-latest'] php: >- ['8.1', '8.2', '8.3', '8.4'] + required-packages: >- + ['data'] From f375b584dbe7992680a20147eac8e52449e91924 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 24 Jul 2025 22:37:30 +0300 Subject: [PATCH 3/3] fix ci --- .github/workflows/sqlite.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index 8fb49fd..48d0da7 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -73,15 +73,15 @@ jobs: - name: Install dependencies with composer. run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Run tests with phpunit with code coverage. - run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always --configuration phpunit.xml.dist - - name: Install Yii Data uses: yiisoft/actions/install-packages@master with: packages: >- ['data'] + - name: Run tests with phpunit with code coverage. + run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always --configuration phpunit.xml.dist + - name: Upload coverage to Codecov. if: matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v3