From a989d4eaf2f5014e132e7c0f6dd8bc4a103a9553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 28 Nov 2023 21:18:25 +0100 Subject: [PATCH 1/6] DEBUG no DB testing --- .github/workflows/test-unit.yml | 180 +------------------------------- 1 file changed, 4 insertions(+), 176 deletions(-) diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 2de578992c..f5e8440b20 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -79,36 +79,13 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1', '8.2', '8.3'] - type: ['Phpunit', 'Phpunit Lowest'] + php: ['7.4', '8.3'] + type: ['Phpunit'] include: - php: 'latest' type: 'Phpunit Burn' env: LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.3' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}" - services: - mysql: - image: mysql - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=atk4_pass_root -e MYSQL_USER=atk4_test_user -e MYSQL_PASSWORD=atk4_pass -e MYSQL_DATABASE=atk4_test - mariadb: - image: mariadb - options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=atk4_pass_root -e MYSQL_USER=atk4_test_user -e MYSQL_PASSWORD=atk4_pass -e MYSQL_DATABASE=atk4_test - postgres: - image: postgres:alpine - env: - POSTGRES_USER: atk4_test_user - POSTGRES_PASSWORD: atk4_pass - POSTGRES_DB: atk4_test - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - mssql: - image: mcr.microsoft.com/mssql/server - env: - ACCEPT_EULA: Y - SA_PASSWORD: atk4_pass - oracle: - image: gvenzl/oracle-xe:18-slim-faststart - env: - ORACLE_PASSWORD: atk4_pass steps: - name: Checkout uses: actions/checkout@v4 @@ -143,10 +120,6 @@ jobs: - name: Init run: | - php -r '(new PDO("mysql:host=mysql", "root", "atk4_pass_root"))->exec("ALTER USER '"'"'atk4_test_user'"'"'@'"'"'%'"'"' WITH MAX_USER_CONNECTIONS 5");' - php -r '(new PDO("mysql:host=mariadb", "root", "atk4_pass_root"))->exec("ALTER USER '"'"'atk4_test_user'"'"'@'"'"'%'"'"' WITH MAX_USER_CONNECTIONS 5");' - php -r '(new PDO("pgsql:host=postgres;dbname=atk4_test", "atk4_test_user", "atk4_pass"))->exec("ALTER ROLE atk4_test_user CONNECTION LIMIT 1");' - /usr/lib/oracle/setup.sh if [ -n "$LOG_COVERAGE" ]; then mkdir coverage; fi - name: "Run tests: SQLite" @@ -155,67 +128,6 @@ jobs: php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-sqlite.cov; fi - - name: "Run tests: MySQL (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "mysql:host=mysql;dbname=atk4_test" - DB_USER: atk4_test_user - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) - if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-mysql.cov; fi - - - name: "Run tests: MariaDB" - if: success() || failure() - env: - DB_DSN: "mysql:host=mariadb;dbname=atk4_test" - DB_USER: atk4_test_user - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) - if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-mariadb.cov; fi - - - name: "Run tests: PostgreSQL (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "pgsql:host=postgres;dbname=atk4_test" - DB_USER: atk4_test_user - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) - if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-postgres.cov; fi - - - name: "Run tests: MSSQL (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "sqlsrv:host=mssql;dbname=master;driverOptions[TrustServerCertificate]=1" - DB_USER: sa - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) - if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-mssql.cov; fi - - - name: "Run tests: Oracle (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "oci:dbname=oracle/free" - DB_USER: system - DB_PASSWORD: atk4_pass - NLS_LANG: AMERICAN_AMERICA.AL32UTF8 - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) - if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-oracle.cov; fi - - name: Upload coverage logs 1/2 (only for latest Phpunit) if: env.LOG_COVERAGE run: | @@ -238,9 +150,8 @@ jobs: strategy: fail-fast: false matrix: - # Selenium with PHP 7.4 and 8.0 was failing too often on initial/create session request, probably because of older (Alpine 3.16) base image - php: ['8.1', '8.2', '8.3'] - type: ['Chrome', 'Chrome Lowest'] + php: ['8.1', '8.3'] + type: ['Chrome'] include: - php: 'latest' type: 'Firefox' @@ -250,29 +161,6 @@ jobs: type: 'Firefox Slow' env: LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.3' && matrix.type == 'Chrome' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}" - services: - mysql: - image: mysql - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=atk4_pass_root -e MYSQL_USER=atk4_test_user -e MYSQL_PASSWORD=atk4_pass -e MYSQL_DATABASE=atk4_test - mariadb: - image: mariadb - options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=atk4_pass_root -e MYSQL_USER=atk4_test_user -e MYSQL_PASSWORD=atk4_pass -e MYSQL_DATABASE=atk4_test - postgres: - image: postgres:alpine - env: - POSTGRES_USER: atk4_test_user - POSTGRES_PASSWORD: atk4_pass - POSTGRES_DB: atk4_test - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - mssql: - image: mcr.microsoft.com/mssql/server - env: - ACCEPT_EULA: Y - SA_PASSWORD: atk4_pass - oracle: - image: gvenzl/oracle-xe:18-slim-faststart - env: - ORACLE_PASSWORD: atk4_pass steps: - name: Checkout uses: actions/checkout@v4 @@ -362,10 +250,6 @@ jobs: - name: Init run: | - php -r '(new PDO("mysql:host=mysql", "root", "atk4_pass_root"))->exec("ALTER USER '"'"'atk4_test_user'"'"'@'"'"'%'"'"' WITH MAX_USER_CONNECTIONS 5");' - php -r '(new PDO("mysql:host=mariadb", "root", "atk4_pass_root"))->exec("ALTER USER '"'"'atk4_test_user'"'"'@'"'"'%'"'"' WITH MAX_USER_CONNECTIONS 5");' - php -r '(new PDO("pgsql:host=postgres;dbname=atk4_test", "atk4_test_user", "atk4_pass"))->exec("ALTER ROLE atk4_test_user CONNECTION LIMIT 1");' - /usr/lib/oracle/setup.sh if [ -n "$LOG_COVERAGE" ]; then mkdir coverage coverage/js; fi ci_wait_until () { timeout 30 sh -c "until { $1 2> /dev/null; }; do sleep 0.02; done" || timeout 15 sh -c "$1" || { echo "health timeout: $1"; exit 1; }; } php -d opcache.enable_cli=1 -S 127.0.0.1:8888 > /dev/null 2>&1 & @@ -383,62 +267,6 @@ jobs: php demos/_demo-data/create-db.php vendor/bin/behat --strict -vv --config behat.yml.dist - - name: "Run tests: MySQL (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "mysql:host=mysql;dbname=atk4_test" - DB_USER: atk4_test_user - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - vendor/bin/behat --strict -vv --config behat.yml.dist - - - name: "Run tests: MariaDB (only for coverage or cron)" - if: (success() || failure()) && (env.LOG_COVERAGE || github.event_name == 'schedule') - env: - DB_DSN: "mysql:host=mariadb;dbname=atk4_test" - DB_USER: atk4_test_user - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - vendor/bin/behat --strict -vv --config behat.yml.dist - - - name: "Run tests: PostgreSQL (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "pgsql:host=postgres;dbname=atk4_test" - DB_USER: atk4_test_user - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - vendor/bin/behat --strict -vv --config behat.yml.dist - - - name: "Run tests: MSSQL (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "sqlsrv:host=mssql;dbname=master;driverOptions[TrustServerCertificate]=1" - DB_USER: sa - DB_PASSWORD: atk4_pass - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - vendor/bin/behat --strict -vv --config behat.yml.dist - - - name: "Run tests: Oracle (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' - env: - DB_DSN: "oci:dbname=oracle/free" - DB_USER: system - DB_PASSWORD: atk4_pass - NLS_LANG: AMERICAN_AMERICA.AL32UTF8 - run: | - sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php - php demos/_demo-data/create-db.php - vendor/bin/behat --strict -vv --config behat.yml.dist - - name: Upload coverage logs 1/2 (only for coverage) if: env.LOG_COVERAGE run: | From dc2da03371b848a31930765fdc68424e942162cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 1 Jun 2024 20:46:47 +0200 Subject: [PATCH 2/6] unify disable and readonly order --- src/Form.php | 2 +- src/Form/Control/Dropdown.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Form.php b/src/Form.php index 84c1128eb9..53181be79b 100644 --- a/src/Form.php +++ b/src/Form.php @@ -432,7 +432,7 @@ protected function loadPost(): void $errors = []; foreach ($this->controls as $k => $control) { // save field value only if field was editable in form at all - if (!$control->readOnly && !$control->disabled) { + if (!$control->disabled && !$control->readOnly) { $postRawValue = $postRawData[$k] ?? null; if ($postRawValue === null) { throw (new Exception('Form POST param does not exist')) diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index c59380feca..d881efd3db 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -201,7 +201,7 @@ protected function renderView(): void $this->template->dangerouslySetHtml('multipleClass', 'multiple'); } - if ($this->readOnly || $this->disabled) { + if ($this->disabled || $this->readOnly) { if ($this->multiple) { $this->jsDropdown(true)->find('a i.delete.icon')->attr('class', 'disabled'); } From fb5ff47506d4a9922246a0e09346b25ccbf900d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 1 Jun 2024 20:47:04 +0200 Subject: [PATCH 3/6] onShow = false no longer needed --- src/Form/Control/Dropdown.php | 2 -- src/Form/Control/Lookup.php | 1 - 2 files changed, 3 deletions(-) diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index d881efd3db..bb3bea1bcb 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -213,8 +213,6 @@ protected function renderView(): void } elseif ($this->readOnly) { $this->template->set('disabledClass', 'read-only'); $this->template->dangerouslySetHtml('disabled', 'readonly="readonly"'); - - $this->setDropdownOption('onShow', new JsFunction([], [new JsExpression('return false')])); } $this->template->set('DefaultText', $this->empty); diff --git a/src/Form/Control/Lookup.php b/src/Form/Control/Lookup.php index e3994d4fe9..79e486f581 100644 --- a/src/Form/Control/Lookup.php +++ b/src/Form/Control/Lookup.php @@ -379,7 +379,6 @@ protected function renderView(): void $this->template->dangerouslySetHtml('disabled', 'readonly="readonly"'); $this->settings['apiSettings'] = null; - $this->settings['onShow'] = new JsFunction([], [new JsExpression('return false')]); } if ($this->dependency) { From 1ba5bbbd01042a7ded280ea88a0499ab07694bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 1 Jun 2024 20:54:31 +0200 Subject: [PATCH 4/6] unset apiSettings for both disable and readonly --- src/Form/Control/Lookup.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Form/Control/Lookup.php b/src/Form/Control/Lookup.php index 79e486f581..969e22f4c8 100644 --- a/src/Form/Control/Lookup.php +++ b/src/Form/Control/Lookup.php @@ -377,7 +377,9 @@ protected function renderView(): void } elseif ($this->readOnly) { $this->template->set('disabledClass', 'read-only'); $this->template->dangerouslySetHtml('disabled', 'readonly="readonly"'); + } + if ($this->disabled || $this->readOnly) { $this->settings['apiSettings'] = null; } From f7fc9cd2cb84693406a78b2e60fb1ad25723abc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 1 Jun 2024 20:58:56 +0200 Subject: [PATCH 5/6] disabled class on a i.delete.icon selector has no effect --- src/Form/Control/Dropdown.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index bb3bea1bcb..982b85f8ce 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -201,12 +201,6 @@ protected function renderView(): void $this->template->dangerouslySetHtml('multipleClass', 'multiple'); } - if ($this->disabled || $this->readOnly) { - if ($this->multiple) { - $this->jsDropdown(true)->find('a i.delete.icon')->attr('class', 'disabled'); - } - } - if ($this->disabled) { $this->template->set('disabledClass', 'disabled'); $this->template->dangerouslySetHtml('disabled', 'disabled="disabled"'); From e0ba76ade52c930ca0941d8f479c1478cd5b7854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 1 Jun 2024 20:59:03 +0200 Subject: [PATCH 6/6] Revert "disabled class on a i.delete.icon selector has no effect" This reverts commit d09c6ddc9842d50cac16c807dd88a2b9438711ca. --- src/Form/Control/Dropdown.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Form/Control/Dropdown.php b/src/Form/Control/Dropdown.php index 982b85f8ce..bb3bea1bcb 100644 --- a/src/Form/Control/Dropdown.php +++ b/src/Form/Control/Dropdown.php @@ -201,6 +201,12 @@ protected function renderView(): void $this->template->dangerouslySetHtml('multipleClass', 'multiple'); } + if ($this->disabled || $this->readOnly) { + if ($this->multiple) { + $this->jsDropdown(true)->find('a i.delete.icon')->attr('class', 'disabled'); + } + } + if ($this->disabled) { $this->template->set('disabledClass', 'disabled'); $this->template->dangerouslySetHtml('disabled', 'disabled="disabled"');