diff --git a/tests/.env.test b/.ci/.env.ci similarity index 92% rename from tests/.env.test rename to .ci/.env.ci index c2f7250d..8d9ee1bf 100644 --- a/tests/.env.test +++ b/.ci/.env.ci @@ -10,7 +10,7 @@ DB_ADAPTER=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_USERNAME=root -DB_PASSWORD= +DB_PASSWORD=secret DB_NAME=vokuro MAIL_FROM_NAME=Vokuro @@ -22,4 +22,4 @@ MAIL_SMTP_USERNAME= MAIL_SMTP_PASSWORD= CODECEPTION_URL=127.0.0.1 -CODECEPTION_PORT=8888 +CODECEPTION_PORT=80 diff --git a/.ci/.env.example b/.ci/.env.example new file mode 100644 index 00000000..becff2ac --- /dev/null +++ b/.ci/.env.example @@ -0,0 +1,25 @@ +APP_CRYPT_SALT=eEAfR|_&G&f,+vU]:jFr!!A&+71w1Ms9~8_4L!<@[N@DyaIP_2My|:+.u>/6m,$D +APP_BASE_URI=/ +APP_PUBLIC_URL=dev.vokuro.phalcon.io + +# Supported adapters are: +# - mysql +# - sqlite +# - pgsql +DB_ADAPTER=mysql +DB_HOST=vokuro-mysql +DB_PORT=3306 +DB_USERNAME=root +DB_PASSWORD=secret +DB_NAME=phalcon_vokuro + +MAIL_FROM_NAME=Vokuro +MAIL_FROM_EMAIL=mail@dev.vokuro.phalcon.io +MAIL_SMTP_SERVER=smtp.gmail.com +MAIL_SMTP_PORT=587 +MAIL_SMTP_SECURITY=tls +MAIL_SMTP_USERNAME= +MAIL_SMTP_PASSWORD= + +CODECEPTION_URL=127.0.0.1 +CODECEPTION_PORT=8888 diff --git a/.ci/create-db.sh b/.ci/create-db.sh index 907ff226..08b2199f 100755 --- a/.ci/create-db.sh +++ b/.ci/create-db.sh @@ -9,7 +9,7 @@ set -e -: "${DB_NAME:=vokuro}" +: "${DB_NAME:=phalcon_vokuro}" case "$DB_ADAPTER" in "mysql") diff --git a/.ci/install-phalcon.sh b/.ci/install-phalcon.sh deleted file mode 100755 index 1d87f3f1..00000000 --- a/.ci/install-phalcon.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# This file is part of the Phalcon Framework. -# -# (c) Phalcon Team -# -# For the full copyright and license information, please view the -# LICENSE.txt file that was distributed with this source code. - -set -e - -: "${PHALCON_VERSION:=master}" - -EXT_DIR="$(php-config --extension-dir)" -LOCAL_PATH="phalcon-$PHALCON_VERSION/php-$(php-config --vernum)/$TRAVIS_ARCH" - -# Using cache only for tagged Phalcon versions -if [ "$PHALCON_VERSION" != "master" ] && - [ "$PHALCON_VERSION" != "4.0.x" ] && - [ -f "$HOME/assets/$LOCAL_PATH/phalcon.so" ] -then - cp "$HOME/assets/$LOCAL_PATH/phalcon.so" "$EXT_DIR/phalcon.so" -else - git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$PHALCON_VERSION" /tmp/phalcon - cd /tmp/phalcon/build || exit 1 - ./install --phpize "$(phpenv which phpize)" --php-config "$(phpenv which php-config)" 1> /dev/null - - mkdir -p "$HOME/assets/$LOCAL_PATH" - cp "$EXT_DIR/phalcon.so" "$HOME/assets/$LOCAL_PATH/phalcon.so" -fi - -echo extension=phalcon.so >> "$(phpenv prefix)/etc/php.ini" - -"$(phpenv which php)" -m | grep -q phalcon diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 4d5d2479..34fbedf8 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -5,8 +5,10 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v1 - - name: Build Vokuro image - run: docker build -t phalconphp/vokuro:4.1.2 -f docker/Dockerfile . + - name: Build Vokuro image 8.0 + run: docker build -t phalconphp/vokuro:5.0.0-8.0 -f docker/8.0/Dockerfile . + + - name: Build Vokuro image 8.1 + run: docker build -t phalconphp/vokuro:5.0.0-8.1 -f docker/8.1/Dockerfile . diff --git a/.github/workflows/validations.yml b/.github/workflows/validations.yml index 69ad839f..de970445 100644 --- a/.github/workflows/validations.yml +++ b/.github/workflows/validations.yml @@ -1,88 +1,98 @@ -name: "Validations" -on: [push, pull_request] -jobs: - validate-code-style: - name: PSR-12 Code style - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Validate composer.json and composer.lock - run: composer validate +name: Testing Suite - - name: Get Composer Cache Directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" +on: [push, pull_request] - - name: Cache composer dependencies - uses: actions/cache@v1 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- +env: + DB_HOST: '127.0.0.1' - - name: Install PHP_CodeSniffer composer package - run: composer global require "squizlabs/php_codesniffer=*" +jobs: + run: + runs-on: ubuntu-latest + name: Workflow - PHP-${{ matrix.php }} - - name: Validate PSR-12 Code Style - run: ~/.composer/vendor/bin/phpcs + services: + mysql: + image: mysql:5.7 + ports: + - "3306:3306" + env: + MYSQL_ROOT_PASSWORD: secret + MYSQL_USER: phalcon + MYSQL_DATABASE: vokuro + MYSQL_PASSWORD: secret - validate-code-static: - name: Static Code with PHP ${{ matrix.php-versions }} - runs-on: ubuntu-latest - env: - extensions: mbstring, intl, json, psr, phalcon-4.0.5 - key: cache-v2.0~14.05.2020 - needs: validate-code-style strategy: fail-fast: false matrix: - php-versions: ['7.2', '7.3', '7.4'] + php: ['8.0', '8.1'] steps: - - name: Checkout the code - uses: actions/checkout@v1 - - - name: Setup cache environment - id: cache-env - uses: shivammathur/cache-extensions@v1 - with: - php-version: ${{ matrix.php-versions }} - extensions: ${{ env.extensions }} - key: ${{ env.key }} - - - name: Cache extensions - uses: actions/cache@v1 - with: - path: ${{ steps.cache-env.outputs.dir }} - key: ${{ steps.cache-env.outputs.key }} - restore-keys: ${{ steps.cache-env.outputs.key }} - + - uses: actions/checkout@v1 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} - extensions: ${{ env.extensions }} + php-version: ${{ matrix.php }} tools: pecl + extensions: mbstring, intl, json, phalcon-5.0.1 + coverage: xdebug - - name: Get Composer Cache Directory + - name: Init Database + run: | + mysql -uroot -h127.0.0.1 -psecret -e 'CREATE DATABASE IF NOT EXISTS `vokuro`;' + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache composer dependencies - uses: actions/cache@v1 + - name: Cache dependencies + uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ matrix.php }}-composer- + + - name: Install Composer dependencies + run: composer install --prefer-dist --no-progress --no-suggest - - name: Install Composer dependencies with PHPStan - run: composer require --prefer-dist --no-progress --no-suggest --dev phpstan/phpstan + - name: Run PHPCS + if: always() + run: vendor/bin/phpcs - name: Run Psalm if: always() run: vendor/bin/psalm --show-info=false - - name: Run PHPStan + - name: Env file if: always() - run: vendor/bin/phpstan analyse -l 5 src + run: cp -v ./.ci/.env.ci ./.env + +# - name: Run migrations +# if: always() +# run: | +# vendor/bin/phinx migrate +# +# - name: Run seeds +# if: always() +# run: | +# vendor/bin/phinx seed:run + + - name: Run tests + if: always() + run: | + sudo php -S 0.0.0.0 -t ./.htrouter.php & + vendor/bin/codecept build + vendor/bin/codecept run unit --coverage-xml=unit-coverage.xml +# vendor/bin/codecept run functional --coverage-xml=functional-coverage.xml +# vendor/bin/codecept run acceptance --coverage-xml=acceptance-coverage.xml + +# - name: Upload to codecov +# uses: codecov/codecov-action@v3 +# with: +# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos +# directory: ./tests/_output/ +# files: unit-coverage.xml,functional-coverage.xml,acceptance-coverage.xml +# name: codecov-umbrella # optional +# fail_ci_if_error: false +# verbose: true # optional (default = false) diff --git a/README.md b/README.md index e6b58465..7cd007eb 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ Thanks. To run this application on your machine, you need at least: -* PHP >= 7.2 -* Phalcon >= 4.0 +* PHP >= 7.4 +* Phalcon >= 5.0 * MySQL >= 5.5 * Apache Web Server with `mod_rewrite enabled`, and `AllowOverride Options` (or `All`) in your `httpd.conf` or Nginx Web Server * Latest [Phalcon Framework](https://github.com/phalcon/cphalcon) extension installed/enabled @@ -28,7 +28,7 @@ To run this application on your machine, you need at least: ### Install Vökuró via composer create-project ```bash -composer create-project phalcon/vokuro /path/to/vokuro-folder "4.1.2" --prefer-dist +composer create-project phalcon/vokuro /path/to/vokuro-folder "5.0.0" --prefer-dist ``` ### Installing Dependencies via Composer @@ -44,7 +44,7 @@ Run the composer installer: ```bash cd vokuro composer install -cp .env.example .env +cp ./.ci/.env.example .env vendor/bin/phinx migrate vendor/bin/phinx seed:run ``` @@ -64,11 +64,11 @@ If you wish to check older versions or newer ones currently under development, p Phalcon is an open source project and a volunteer effort. Vökuró does not have human resources fully dedicated to the maintenance of this software. -If you want something to be improved or you want a new feature please submit a Pull Request. +If you want something to be improved, or you want a new feature please submit a Pull Request. ## Sponsors -Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/phalcon#sponsor)] +Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/phalcon#sponsor)] sponsors diff --git a/codeception.yml b/codeception.yml index e6cc38eb..66f5e65e 100644 --- a/codeception.yml +++ b/codeception.yml @@ -29,7 +29,7 @@ extensions: # Get params from .env file params: - - tests/.env.test + - .env error_level: "E_ALL" diff --git a/composer.json b/composer.json index 92e63bf4..99c3697b 100644 --- a/composer.json +++ b/composer.json @@ -25,21 +25,21 @@ } ], "require": { - "php": ">=7.2", + "php": ">=7.4", "ext-openssl": "*", - "ext-phalcon": "~4.0.0", - "robmorgan/phinx": "^0.11.1", - "swiftmailer/swiftmailer": "^6.2", - "vlucas/phpdotenv": "^3.6" + "ext-phalcon": "^5.0.0", + "robmorgan/phinx": "^0.12.12", + "symfony/mailer": "^6.0", + "vlucas/phpdotenv": "^5.4" }, "require-dev": { - "codeception/codeception": "^4.1.6", - "phalcon/ide-stubs": "4.0.6", - "phpunit/phpunit": "^8.4", - "squizlabs/php_codesniffer": "3.5.5", - "vimeo/psalm": "^3.7", - "codeception/module-phpbrowser": "^1.0", - "codeception/module-asserts": "^1.2" + "codeception/codeception": "^5.0", + "codeception/module-asserts": "^3.0", + "codeception/module-phpbrowser": "^3.0", + "phalcon/ide-stubs": "^v5.0.1", + "squizlabs/php_codesniffer": "^3.7", + "vimeo/psalm": "^4.27", + "phpstan/phpstan": "^1.8" }, "suggest": { "ext-apc": "Needed to support caching ACL" @@ -56,7 +56,6 @@ "exclude": [ "/.ci", ".dockerignore", - ".travis.yml", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md" ] diff --git a/config/acl.php b/config/acl.php index 3751a2a1..67c5f8eb 100644 --- a/config/acl.php +++ b/config/acl.php @@ -1,5 +1,4 @@ [ 'users' => [ diff --git a/config/config.php b/config/config.php index b834ef7d..f738533e 100644 --- a/config/config.php +++ b/config/config.php @@ -1,5 +1,4 @@ [ - 'adapter' => getenv('DB_ADAPTER'), - 'host' => getenv('DB_HOST'), - 'port' => getenv('DB_PORT'), - 'username' => getenv('DB_USERNAME'), - 'password' => getenv('DB_PASSWORD'), - 'dbname' => getenv('DB_NAME'), + 'adapter' => $_ENV['DB_ADAPTER'] ?? 'mysql', + 'host' => $_ENV['DB_HOST'] ?? '127.0.0.1', + 'port' => $_ENV['DB_PORT'] ?? 3306, + 'username' => $_ENV['DB_USERNAME'] ?? 'root', + 'password' => $_ENV['DB_PASSWORD'] ?? 'secret', + 'dbname' => $_ENV['DB_NAME'] ?? 'phalcon_vokuro', ], 'application' => [ - 'baseUri' => getenv('APP_BASE_URI'), - 'publicUrl' => getenv('APP_PUBLIC_URL'), - 'cryptSalt' => getenv('APP_CRYPT_SALT'), + 'baseUri' => $_ENV['APP_BASE_URI'] ?? '/', + 'publicUrl' => $_ENV['APP_PUBLIC_URL'] ?? 'https://vokuro.phalcon.ld', + 'cryptSalt' => $_ENV['APP_CRYPT_SALT'] ?? '', 'viewsDir' => root_path('themes/vokuro/'), 'cacheDir' => root_path('var/cache/'), 'sessionSavePath' => root_path('var/cache/session/'), ], 'mail' => [ - 'fromName' => getenv('MAIL_FROM_NAME'), - 'fromEmail' => getenv('MAIL_FROM_EMAIL'), + 'fromName' => $_ENV['MAIL_FROM_NAME'] ?? 'Vokuro Mailer', + 'fromEmail' => $_ENV['MAIL_FROM_EMAIL'] ?? 'vokuro@localhost', 'smtp' => [ - 'server' => getenv('MAIL_SMTP_SERVER'), - 'port' => getenv('MAIL_SMTP_PORT'), - 'security' => getenv('MAIL_SMTP_SECURITY'), - 'username' => getenv('MAIL_SMTP_USERNAME'), - 'password' => getenv('MAIL_SMTP_PASSWORD'), + 'server' => $_ENV['MAIL_SMTP_SERVER'] ?? 'localhost', + 'port' => $_ENV['MAIL_SMTP_PORT'] ?? 25, + 'security' => $_ENV['MAIL_SMTP_SECURITY'] ?? '', + 'username' => $_ENV['MAIL_SMTP_USERNAME'] ?? '', + 'password' => $_ENV['MAIL_SMTP_PASSWORD'] ?? '', ], ], 'logger' => [ 'path' => root_path('var/logs/'), - 'format' => '%date% [%type%] %message%', + 'format' => '%date% [%level%] %message%', 'date' => 'D j H:i:s', - 'logLevel' => Logger::DEBUG, + 'logLevel' => Enum::DEBUG, 'filename' => 'application.log', ], - // Set to false to disable sending emails (for use in test environment) + // Set to false, to disable sending emails (for use in test environment) 'useMail' => true, ]; diff --git a/config/providers.php b/config/providers.php index 38ed0cd4..4dd4eacd 100644 --- a/config/providers.php +++ b/config/providers.php @@ -1,5 +1,4 @@ " \ + description="The PHP image to test the Vökuró example concepts" + +ENV PHALCON_VERSION="5.0.1" \ + PHP_VERSION="8.0" + +# Update +RUN apt update -y && \ + apt install -y \ + apt-utils \ + gettext \ + git \ + libzip-dev \ + nano \ + sudo \ + wget \ + zip + +# PECL Packages +RUN pecl install -o -f redis && \ + pecl install phalcon-${PHALCON_VERSION} \ + xdebug + +# Install PHP extensions +RUN docker-php-ext-install \ + gettext \ + pdo_mysql \ + zip + +# Install PHP extensions +RUN docker-php-ext-enable \ + opcache \ + phalcon \ + redis \ + xdebug + +# Clear cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Add user +RUN groupadd -g 1000 phalcon +RUN useradd -u 1000 -ms /bin/bash -g phalcon phalcon + +# Composer +COPY --from=composer /usr/bin/composer /usr/local/bin/composer + +# Copy existing application directory contents +COPY . /code + +# Bash script with helper aliases +COPY ./config/.bashrc /root/.bashrc +COPY ./config/.bashrc /home/phalcon/.bashrc + +# Copy existing application directory permissions +COPY --chown=phalcon:phalcon . /code + +# Change current user to phalcon +USER phalcon + +EXPOSE 80 + +CMD ["php", "-S", "0.0.0.0:80", "-t", "public/", ".htrouter.php"] diff --git a/docker/8.0/config/extra.ini b/docker/8.0/config/extra.ini new file mode 100644 index 00000000..ec632f51 --- /dev/null +++ b/docker/8.0/config/extra.ini @@ -0,0 +1,8 @@ +error_reporting = E_ALL +display_errors = "On" +display_startup_errors = "On" +log_errors = "On" +error_log = /srv/storage/logs/php_errors.log +memory_limit = 512M +apc.enable_cli = "On" +session.save_path = "/tmp" diff --git a/docker/8.1/Dockerfile b/docker/8.1/Dockerfile new file mode 100644 index 00000000..5d6c557b --- /dev/null +++ b/docker/8.1/Dockerfile @@ -0,0 +1,69 @@ +FROM composer:latest as composer +FROM php:8.1-fpm + +# Set working directory +WORKDIR /code + +LABEL vendor="Phalcon" \ + maintainer="Phalcon Team " \ + description="The PHP image to test the Vökuró example concepts" + +ENV PHALCON_VERSION="5.0.1" \ + PHP_VERSION="8.1" + +# Update +RUN apt update -y && \ + apt install -y \ + apt-utils \ + gettext \ + git \ + libzip-dev \ + nano \ + sudo \ + wget \ + zip + +# PECL Packages +RUN pecl install -o -f redis && \ + pecl install phalcon-${PHALCON_VERSION} \ + xdebug + +# Install PHP extensions +RUN docker-php-ext-install \ + gettext \ + pdo_mysql \ + zip + +# Install PHP extensions +RUN docker-php-ext-enable \ + opcache \ + phalcon \ + redis \ + xdebug + +# Clear cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Add user +RUN groupadd -g 1000 phalcon +RUN useradd -u 1000 -ms /bin/bash -g phalcon phalcon + +# Composer +COPY --from=composer /usr/bin/composer /usr/local/bin/composer + +# Copy existing application directory contents +COPY . /code + +# Bash script with helper aliases +COPY config/.bashrc /root/.bashrc +COPY config/.bashrc /home/phalcon/.bashrc + +# Copy existing application directory permissions +COPY --chown=phalcon:phalcon . /code + +# Change current user to phalcon +USER phalcon + +EXPOSE 80 + +CMD ["php", "-S", "0.0.0.0:80", "-t", "public/", ".htrouter.php"] diff --git a/docker/8.1/config/extra.ini b/docker/8.1/config/extra.ini new file mode 100644 index 00000000..ec632f51 --- /dev/null +++ b/docker/8.1/config/extra.ini @@ -0,0 +1,8 @@ +error_reporting = E_ALL +display_errors = "On" +display_startup_errors = "On" +log_errors = "On" +error_log = /srv/storage/logs/php_errors.log +memory_limit = 512M +apc.enable_cli = "On" +session.save_path = "/tmp" diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index bdc5e6a7..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# docker build -t phalconphp/vokuro:4.1.2 -f docker/Dockerfile . - -# debian/buster -FROM php:7.4-cli - -ENV VERSION=4.1.2 - -LABEL version="$VERSION" \ - vendor="Phalcon" \ - maintainer="Phalcon Team " \ - description="The PHP image to test Vökuró example concepts" - -ADD . /code - -WORKDIR /code - -RUN apt update \ - && curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | bash \ - && apt update -y \ - && apt install php7.4-phalcon \ - && docker-php-ext-install opcache pdo_mysql mysqli 1> /dev/null \ - && printf "\\n" | pecl install --force psr 1> /dev/null \ - && docker-php-ext-enable psr \ - && docker-php-ext-enable phalcon \ - && php -m | grep -i "opcache\|mysql\|phalcon\|psr\|pdo\|mbstring" \ - && mv /code/.env.example /code/.env \ - && apt-get autoremove -y \ - && apt-get autoclean -y \ - && apt-get clean -y \ - && rm -rf /tmp/* /var/tmp/* \ - && find /var/cache/apt/archives /var/lib/apt/lists /var/cache \ - -not -name lock \ - -type f \ - -delete \ - && find /var/log -type f | while read f; do echo -n '' > ${f}; done - -EXPOSE 80 - -# docker run -p 80:80 phalconphp/vokuro:4.1.2 -CMD ["php", "-S", "0.0.0.0:80", "-t", "public/", ".htrouter.php"] diff --git a/phinx.php b/phinx.php index 0cbf3e62..bf727490 100644 --- a/phinx.php +++ b/phinx.php @@ -2,32 +2,39 @@ use Dotenv\Dotenv; -$dotenv = Dotenv::create(__DIR__); -$dotenv->load(); +(Dotenv::createImmutable(__DIR__))->load(); -return -[ - 'paths' => [ +$adapter = strtolower($_ENV['DB_ADAPTER'] ?? 'mysql'); +$host = $_ENV['DB_HOST'] ?? 'localhost'; +$user = $_ENV['DB_USERNAME'] ?? 'root'; +$pass = $_ENV['DB_PASSWORD'] ?? ''; +$port = $_ENV['DB_PORT'] ?? 3306; +$name = $_ENV['DB_NAME'] ?? 'phalcon_vokuro'; + +if ('sqlite' === $adapter) { + $name = '%%PHINX_CONFIG_DIR%%/db/' . $name; +} + +return [ + 'paths' => [ 'migrations' => [ 'Vokuro\\Migrations' => '%%PHINX_CONFIG_DIR%%/db/migrations' ], - 'seeds' => [ + 'seeds' => [ 'Vokuro\\Seeds' => '%%PHINX_CONFIG_DIR%%/db/seeds', ], ], - 'environments' => [ + 'environments' => [ 'default_migration_table' => 'phinxlog', - 'default_database' => 'development', - 'development' => [ - 'adapter' => strtolower(getenv('DB_ADAPTER')), - 'host' => getenv('DB_HOST'), - 'name' => strtolower(getenv('DB_ADAPTER')) === 'sqlite' ? - '%%PHINX_CONFIG_DIR%%/db/' . getenv('DB_NAME') : - getenv('DB_NAME'), - 'user' => getenv('DB_USERNAME'), - 'pass' => getenv('DB_PASSWORD'), - 'port' => getenv('DB_PORT'), - 'charset' => 'utf8', + 'default_database' => 'development', + 'development' => [ + 'adapter' => $adapter, + 'host' => $host, + 'name' => $name, + 'user' => $user, + 'pass' => $pass, + 'port' => $port, + 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', ], ], diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f6c3a616..69e04b8e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,9 @@ parameters: - bootstrap: %rootDir%/../../../vendor/autoload.php - + level: 5 + paths: + - src + bootstrapFiles: + - %rootDir%/../../../vendor/autoload.php ignoreErrors: - '#Parameter \#1 \$eventsManager of method Phalcon#' reportUnmatchedIgnoredErrors: false diff --git a/psalm.xml.dist b/psalm.xml.dist index e45c0a31..57dab7d0 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -1,6 +1,5 @@ load(); + (Dotenv::createImmutable($rootPath))->load(); /** * Run Vökuró! diff --git a/src/Application.php b/src/Application.php index 2db8959a..4a060d5f 100644 --- a/src/Application.php +++ b/src/Application.php @@ -1,5 +1,4 @@ di = new FactoryDefault(); - $this->app = $this->createApplication(); + $this->di = new FactoryDefault(); + $this->app = $this->createApplication(); $this->rootPath = $rootPath; $this->di->setShared(self::APPLICATION_PROVIDER, $this); @@ -67,14 +68,17 @@ public function __construct(string $rootPath) */ public function run(): string { - $baseUri = $this->di->getShared('url')->getBaseUri(); - $position = strpos($_SERVER['REQUEST_URI'], $baseUri) + strlen($baseUri); - $uri = '/' . substr($_SERVER['REQUEST_URI'], $position); + $baseUri = $this->di->getShared('url') + ->getBaseUri() + ; + $uri = $_SERVER['REQUEST_URI'] ?? '/'; + $position = (int) strpos($uri, $baseUri) + strlen($baseUri); + $uri = '/' . substr($uri, $position); /** @var ResponseInterface $response */ $response = $this->app->handle($uri); - return (string)$response->getContent(); + return (string) $response->getContent(); } /** @@ -108,7 +112,7 @@ protected function initializeProviders(): void $providers = include_once $filename; foreach ($providers as $providerClass) { /** @var ServiceProviderInterface $provider */ - $provider = new $providerClass; + $provider = new $providerClass(); $provider->register($this->di); } } diff --git a/src/Controllers/PermissionsController.php b/src/Controllers/PermissionsController.php index bb9f074e..864fefe3 100644 --- a/src/Controllers/PermissionsController.php +++ b/src/Controllers/PermissionsController.php @@ -1,5 +1,4 @@ view->setTemplateBefore('private'); + //default select option value + $selectedOption = 0; if ($this->request->isPost()) { - $profile = Profiles::findFirstById($this->request->getPost('profileId')); + $selectedOption = $this->request->getPost('profileId'); + $profile = Profiles::findFirstById($selectedOption); if ($profile) { if ($this->request->hasPost('permissions') && $this->request->hasPost('submit')) { // Deletes the current permissions - $profile->getPermissions()->delete(); + $profile->getPermissions() + ->delete() + ; // Save the new permissions foreach ($this->request->getPost('permissions') as $permission) { @@ -67,19 +75,23 @@ public function indexAction(): void ], ]); - $profilesSelect = $this->tag->select([ - 'profileId', - $profiles, - 'using' => [ - 'id', - 'name', - ], - 'useEmpty' => true, - 'emptyText' => '...', - 'emptyValue' => '', - 'class' => 'form-control mr-sm-2', - ]); + $options = [ + 'id' => 'profileId', + 'name' => 'profileId', + 'class' => 'form-control mr-sm-2' + ]; + + $select = $this + ->tag + ->inputSelect(' ', PHP_EOL, $options) + ->addPlaceholder('...', '', [], true) + ->selected((string) $selectedOption) + ; + + foreach ($profiles as $profile) { + $select->add($profile->name, (string) $profile->id); + } - $this->view->setVar('profilesSelect', $profilesSelect); + $this->view->setVar('profilesSelect', $select); } } diff --git a/src/Forms/ChangePasswordForm.php b/src/Forms/ChangePasswordForm.php index 6ed94f6d..2c23633c 100644 --- a/src/Forms/ChangePasswordForm.php +++ b/src/Forms/ChangePasswordForm.php @@ -14,9 +14,9 @@ use Phalcon\Forms\Element\Password; use Phalcon\Forms\Form; -use Phalcon\Validation\Validator\Confirmation; -use Phalcon\Validation\Validator\PresenceOf; -use Phalcon\Validation\Validator\StringLength; +use Phalcon\Filter\Validation\Validator\Confirmation; +use Phalcon\Filter\Validation\Validator\PresenceOf; +use Phalcon\Filter\Validation\Validator\StringLength; class ChangePasswordForm extends Form { diff --git a/src/Forms/ForgotPasswordForm.php b/src/Forms/ForgotPasswordForm.php index 64473b0c..ff61cbb7 100644 --- a/src/Forms/ForgotPasswordForm.php +++ b/src/Forms/ForgotPasswordForm.php @@ -15,8 +15,8 @@ use Phalcon\Forms\Element\Submit; use Phalcon\Forms\Element\Text; use Phalcon\Forms\Form; -use Phalcon\Validation\Validator\Email; -use Phalcon\Validation\Validator\PresenceOf; +use Phalcon\Filter\Validation\Validator\Email; +use Phalcon\Filter\Validation\Validator\PresenceOf; class ForgotPasswordForm extends Form { diff --git a/src/Forms/LoginForm.php b/src/Forms/LoginForm.php index 8dc2043b..32e207bd 100644 --- a/src/Forms/LoginForm.php +++ b/src/Forms/LoginForm.php @@ -18,9 +18,9 @@ use Phalcon\Forms\Element\Submit; use Phalcon\Forms\Element\Text; use Phalcon\Forms\Form; -use Phalcon\Validation\Validator\Email; -use Phalcon\Validation\Validator\Identical; -use Phalcon\Validation\Validator\PresenceOf; +use Phalcon\Filter\Validation\Validator\Email; +use Phalcon\Filter\Validation\Validator\Identical; +use Phalcon\Filter\Validation\Validator\PresenceOf; class LoginForm extends Form { diff --git a/src/Forms/ProfilesForm.php b/src/Forms/ProfilesForm.php index 9e6d4285..d8d3e26e 100644 --- a/src/Forms/ProfilesForm.php +++ b/src/Forms/ProfilesForm.php @@ -16,7 +16,7 @@ use Phalcon\Forms\Element\Select; use Phalcon\Forms\Element\Text; use Phalcon\Forms\Form; -use Phalcon\Validation\Validator\PresenceOf; +use Phalcon\Filter\Validation\Validator\PresenceOf; class ProfilesForm extends Form { diff --git a/src/Forms/SignUpForm.php b/src/Forms/SignUpForm.php index 5e0f5b5a..5d6b531b 100644 --- a/src/Forms/SignUpForm.php +++ b/src/Forms/SignUpForm.php @@ -18,11 +18,11 @@ use Phalcon\Forms\Element\Submit; use Phalcon\Forms\Element\Text; use Phalcon\Forms\Form; -use Phalcon\Validation\Validator\Confirmation; -use Phalcon\Validation\Validator\Email; -use Phalcon\Validation\Validator\Identical; -use Phalcon\Validation\Validator\PresenceOf; -use Phalcon\Validation\Validator\StringLength; +use Phalcon\Filter\Validation\Validator\Confirmation; +use Phalcon\Filter\Validation\Validator\Email; +use Phalcon\Filter\Validation\Validator\Identical; +use Phalcon\Filter\Validation\Validator\PresenceOf; +use Phalcon\Filter\Validation\Validator\StringLength; class SignUpForm extends Form { diff --git a/src/Forms/UsersForm.php b/src/Forms/UsersForm.php index 1ed37491..5494e9ad 100644 --- a/src/Forms/UsersForm.php +++ b/src/Forms/UsersForm.php @@ -16,8 +16,8 @@ use Phalcon\Forms\Element\Select; use Phalcon\Forms\Element\Text; use Phalcon\Forms\Form; -use Phalcon\Validation\Validator\Email; -use Phalcon\Validation\Validator\PresenceOf; +use Phalcon\Filter\Validation\Validator\Email; +use Phalcon\Filter\Validation\Validator\PresenceOf; use Vokuro\Models\Profiles; class UsersForm extends Form diff --git a/src/Helpers.php b/src/Helpers.php index b0af6fd3..9b085b2e 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -3,7 +3,7 @@ namespace Vokuro; -use Phalcon\Di; +use Phalcon\Di\Di; use Phalcon\Di\DiInterface; /** diff --git a/src/Models/Users.php b/src/Models/Users.php index 518f8308..4c1fda7a 100644 --- a/src/Models/Users.php +++ b/src/Models/Users.php @@ -13,9 +13,9 @@ namespace Vokuro\Models; use Phalcon\Mvc\Model; -use Phalcon\Security; -use Phalcon\Validation; -use Phalcon\Validation\Validator\Uniqueness; +use Phalcon\Encryption\Security; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\Uniqueness; /** * All the users registered in the application diff --git a/src/Plugins/Acl/Acl.php b/src/Plugins/Acl/Acl.php index 1a27912d..90ba9e7f 100644 --- a/src/Plugins/Acl/Acl.php +++ b/src/Plugins/Acl/Acl.php @@ -1,5 +1,4 @@ @@ -88,7 +89,9 @@ public function isPrivate($controllerName): bool */ public function isAllowed($profile, $controller, $action): bool { - return $this->getAcl()->isAllowed($profile, $controller, $action); + return $this->getAcl() + ->isAllowed($profile, $controller, $action) + ; } /** @@ -230,7 +233,7 @@ public function rebuild(): AclMemory */ protected function getFilePath() { - if (!isset($this->filePath)) { + if (true === empty($this->filePath)) { $this->filePath = rtrim($this->config->application->cacheDir, '\\/') . '/acl/data.txt'; } diff --git a/src/Plugins/Mail/Mail.php b/src/Plugins/Mail/Mail.php index 02901292..f6bc9ff7 100644 --- a/src/Plugins/Mail/Mail.php +++ b/src/Plugins/Mail/Mail.php @@ -1,5 +1,4 @@ config->mail; $template = $this->getTemplate($name, $params); + $mailUsername = $mailSettings->smtp->username; + if (true !== empty($mailUsername)) { + $mailUsername .= ':' . $mailSettings->smtp->password; + } + // Create the message - $message = new Message(); + $message = new Email(); $message - ->setSubject($subject) - ->setTo($to) - ->setFrom([$mailSettings->fromEmail => $mailSettings->fromName]) - ->setBody($template, 'text/html'); + ->subject($subject) + ->from(new Address($mailSettings->fromEmail, $mailSettings->fromName)) + ->to(...$to) + ->text($template) + ; - $transport = new Smtp($mailSettings->smtp->server, $mailSettings->smtp->port, $mailSettings->smtp->security); - $transport - ->setUsername($mailSettings->smtp->username) - ->setPassword($mailSettings->smtp->password); + $dsn = sprintf( + 'smtp://%s@%s:%s', + $mailUsername, + $mailSettings->smtp->server, + $mailSettings->smtp->port + ); + $transport = Transport::fromDsn($dsn); - return (new Swift_Mailer($transport))->send($message); + (new Mailer($transport))->send($message); } /** diff --git a/src/Providers/AclProvider.php b/src/Providers/AclProvider.php index f4bbcf65..cc4431bf 100644 --- a/src/Providers/AclProvider.php +++ b/src/Providers/AclProvider.php @@ -1,5 +1,4 @@ getRootPath(); - $di->setShared($this->providerName, function () use ($rootPath) { - $filename = $rootPath . '/config/acl.php'; - $privateResources = []; - if (is_readable($filename)) { - $privateResources = include $filename; - if (!empty($privateResources['private'])) { - $privateResources = $privateResources['private']; + $di->setShared( + $this->providerName, + function () use ($rootPath) { + $filename = $rootPath . '/config/acl.php'; + $privateResources = []; + if (is_readable($filename)) { + $privateResources = include $filename; + if (!empty($privateResources['private'])) { + $privateResources = $privateResources['private']; + } } - } - $acl = new Acl(); - $acl->addPrivateResources($privateResources); + $acl = new Acl(); + $acl->addPrivateResources($privateResources); - return $acl; - }); + return $acl; + } + ); } } diff --git a/src/Providers/AssetsProvider.php b/src/Providers/AssetsProvider.php index f0fb325d..11e387e9 100644 --- a/src/Providers/AssetsProvider.php +++ b/src/Providers/AssetsProvider.php @@ -1,5 +1,4 @@ setShared($this->providerName, function () use ($assetManager) { + /** @var TagFactory $tagFactory */ + $tagFactory = $di->getShared('tag'); - $assetManager->collection('css') - ->addCss( - '//stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css?dc=' . self::VERSION, - false, - false, - [ - "media" => "screen,projection", - "integrity" => "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T", - "crossorigin" => "anonymous" - ] - ) - ->addCss('/css/style.css?dc=' . self::VERSION, true, true, [ - "media" => "screen,projection" - ]); + $di->setShared( + $this->providerName, + function () use ($tagFactory) { + $assetManager = new Manager($tagFactory); + $assetManager->collection('css') + ->addCss( + '//cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css?dc=' . self::VERSION, + false, + false, + [ + 'media' => 'screen,projection', + 'integrity' => 'sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N', + 'crossorigin' => 'anonymous' + ] + ) + ->addCss('/css/style.css?dc=' . self::VERSION, true, true, [ + 'media' => 'screen,projection' + ]) + ; - $assetManager->collection('js') - ->addJs('//code.jquery.com/jquery-3.3.1.slim.min.js?dc=' . self::VERSION, false, true, [ - "integrity" => "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo", - "crossorigin" => "anonymous" - ]) - ->addJs( - '//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js?dc=' . self::VERSION, - false, - true, - [ - "integrity" => "sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM", - "crossorigin" => "anonymous" - ] - ); + $assetManager->collection('js') + ->addJs( + '//code.jquery.com/jquery-3.6.1.slim.min.js?dc=' . self::VERSION, + false, + true, + [ + 'integrity' => 'sha256-w8CvhFs7iHNVUtnSP0YKEg00p9Ih13rlL9zGqvLdePA=', + 'crossorigin' => 'anonymous' + ] + ) + ->addJs( + '//cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js?dc=' . self::VERSION, + false, + true, + [ + 'integrity' => 'sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+', + 'crossorigin' => 'anonymous' + ] + ) + ; - return $assetManager; - }); + return $assetManager; + } + ); } } diff --git a/src/Providers/ConfigProvider.php b/src/Providers/ConfigProvider.php index ca96ccb4..58a418b6 100644 --- a/src/Providers/ConfigProvider.php +++ b/src/Providers/ConfigProvider.php @@ -12,7 +12,7 @@ namespace Vokuro\Providers; -use Phalcon\Config; +use Phalcon\Config\Config; use Phalcon\Di\DiInterface; use Phalcon\Di\ServiceProviderInterface; use Vokuro\Application; diff --git a/src/Providers/CryptProvider.php b/src/Providers/CryptProvider.php index 7af441b7..d41a778c 100644 --- a/src/Providers/CryptProvider.php +++ b/src/Providers/CryptProvider.php @@ -12,7 +12,7 @@ namespace Vokuro\Providers; -use Phalcon\Crypt; +use Phalcon\Encryption\Crypt; use Phalcon\Di\DiInterface; use Phalcon\Di\ServiceProviderInterface; @@ -31,13 +31,17 @@ class CryptProvider implements ServiceProviderInterface public function register(DiInterface $di): void { /** @var string $cryptSalt */ - $cryptSalt = $di->getShared('config')->path('application.cryptSalt'); + $cryptSalt = $di->getShared('config') + ->path('application.cryptSalt'); - $di->set($this->providerName, function () use ($cryptSalt) { - $crypt = new Crypt(); - $crypt->setKey($cryptSalt); + $di->set( + $this->providerName, + function () use ($cryptSalt) { + $crypt = new Crypt(); + $crypt->setKey($cryptSalt); - return $crypt; - }); + return $crypt; + } + ); } } diff --git a/src/Providers/DbProvider.php b/src/Providers/DbProvider.php index ecae3b0f..ede94768 100644 --- a/src/Providers/DbProvider.php +++ b/src/Providers/DbProvider.php @@ -1,5 +1,4 @@ Pdo\Mysql::class, 'pgsql' => Pdo\Postgresql::class, 'sqlite' => Pdo\Sqlite::class, @@ -47,13 +49,18 @@ class DbProvider implements ServiceProviderInterface public function register(DiInterface $di): void { /** @var Config $config */ - $config = $di->getShared('config')->get('database'); + $config = $di->getShared('config') + ->get('database') + ; $class = $this->getClass($config); $config = $this->createConfig($config); - $di->set($this->providerName, function () use ($class, $config) { - return new $class($config); - }); + $di->set( + $this->providerName, + function () use ($class, $config) { + return new $class($config); + } + ); } /** diff --git a/src/Providers/FlashProvider.php b/src/Providers/FlashProvider.php index 7d65115e..3e740781 100644 --- a/src/Providers/FlashProvider.php +++ b/src/Providers/FlashProvider.php @@ -1,5 +1,4 @@ set($this->providerName, function () { - $escaper = new Escaper(); - $flash = new Flash($escaper); - $flash->setImplicitFlush(false); - $flash->setCssClasses([ - 'error' => 'alert alert-danger', - 'success' => 'alert alert-success', - 'notice' => 'alert alert-info', - 'warning' => 'alert alert-warning', - ]); + $escaper = $di->getShared('escaper'); + $di->set( + $this->providerName, + function () use ($escaper) { + $flash = new Flash($escaper); + $flash->setImplicitFlush(false); + $flash->setCssClasses( + [ + 'error' => 'alert alert-danger', + 'success' => 'alert alert-success', + 'notice' => 'alert alert-info', + 'warning' => 'alert alert-warning', + ] + ); - return $flash; - }); + return $flash; + } + ); } } diff --git a/src/Providers/LoggerProvider.php b/src/Providers/LoggerProvider.php index 0eadca08..774256a4 100644 --- a/src/Providers/LoggerProvider.php +++ b/src/Providers/LoggerProvider.php @@ -12,11 +12,12 @@ namespace Vokuro\Providers; -use Phalcon\Config; +use Phalcon\Config\Config; use Phalcon\Di\DiInterface; use Phalcon\Di\ServiceProviderInterface; use Phalcon\Logger\Adapter\Stream as FileLogger; use Phalcon\Logger\Formatter\Line as FormatterLine; +use Phalcon\Logger\Logger; /** * Logger service @@ -39,13 +40,20 @@ public function register(DiInterface $di): void $loggerConfigs = $di->getShared('config')->get('logger'); $di->set($this->providerName, function () use ($loggerConfigs) { - $filename = trim($loggerConfigs->get('filename'), '\\/'); - $path = rtrim($loggerConfigs->get('path'), '\\/') . DIRECTORY_SEPARATOR; - $formatter = new FormatterLine($loggerConfigs->get('format'), $loggerConfigs->get('date')); - $logger = new FileLogger($path . $filename); + $loggerAdapter = new FileLogger($loggerConfigs->get('path') . $loggerConfigs->get('filename')); - $logger->setFormatter($formatter); + $loggerFormatter = new FormatterLine($loggerConfigs->get('format'), $loggerConfigs->get('date')); + $loggerAdapter->setFormatter($loggerFormatter); + + $logger = new Logger( + 'messages', + [ + 'main' => $loggerAdapter, + ] + ); + + $logger->setLogLevel($loggerConfigs->get('logLevel')); return $logger; }); diff --git a/src/Providers/ModelsMetadataProvider.php b/src/Providers/ModelsMetadataProvider.php index 57f1ae61..c0b09e05 100644 --- a/src/Providers/ModelsMetadataProvider.php +++ b/src/Providers/ModelsMetadataProvider.php @@ -1,5 +1,4 @@ getShared('config')->path('application.cacheDir'); - $di->set($this->providerName, function () use ($cacheDir) { - return new MetaDataAdapter([ - 'metaDataDir' => $cacheDir . 'metaData/', - ]); - }); + $cacheDir = $di->getShared('config') + ->path('application.cacheDir') + ; + $di->set( + $this->providerName, + function () use ($cacheDir) { + return new MetaDataAdapter( + [ + 'metaDataDir' => $cacheDir . 'metaData/', + ] + ); + } + ); } } diff --git a/src/Providers/SecurityProvider.php b/src/Providers/SecurityProvider.php index bb9462d3..f94dcd90 100644 --- a/src/Providers/SecurityProvider.php +++ b/src/Providers/SecurityProvider.php @@ -14,7 +14,7 @@ use Phalcon\Di\DiInterface; use Phalcon\Di\ServiceProviderInterface; -use Phalcon\Security; +use Phalcon\Encryption\Security; class SecurityProvider implements ServiceProviderInterface { diff --git a/src/Providers/SessionBagProvider.php b/src/Providers/SessionBagProvider.php index 76291835..58b48e23 100644 --- a/src/Providers/SessionBagProvider.php +++ b/src/Providers/SessionBagProvider.php @@ -1,5 +1,4 @@ set($this->providerName, function () { - return new Bag('conditions'); - }); + $session = $di->get('session'); + $di->set( + $this->providerName, + function () use ($session) { + return new Bag($session, 'conditions'); + } + ); } } diff --git a/src/Providers/UrlProvider.php b/src/Providers/UrlProvider.php index baa88023..177c59ec 100644 --- a/src/Providers/UrlProvider.php +++ b/src/Providers/UrlProvider.php @@ -14,7 +14,7 @@ use Phalcon\Di\DiInterface; use Phalcon\Di\ServiceProviderInterface; -use Phalcon\Url as UrlResolver; +use Phalcon\Mvc\Url as UrlResolver; class UrlProvider implements ServiceProviderInterface { diff --git a/src/Providers/ViewProvider.php b/src/Providers/ViewProvider.php index 3d3cc5b8..06fbb3c6 100644 --- a/src/Providers/ViewProvider.php +++ b/src/Providers/ViewProvider.php @@ -12,7 +12,7 @@ namespace Vokuro\Providers; -use Phalcon\Config; +use Phalcon\Config\Config; use Phalcon\Di\DiInterface; use Phalcon\Di\ServiceProviderInterface; use Phalcon\Mvc\View; diff --git a/tests/_data/.gitkeep b/tests/_data/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/_output/.gitignore b/tests/_output/.gitignore deleted file mode 100644 index c96a04f0..00000000 --- a/tests/_output/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/tests/_support/_generated/.gitignore b/tests/_support/_generated/.gitignore deleted file mode 100644 index c96a04f0..00000000 --- a/tests/_support/_generated/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/tests/acceptance/controllers/AboutControllerCest.php b/tests/acceptance/controllers/AboutControllerCest.php index 64f956fc..9cfc15ab 100644 --- a/tests/acceptance/controllers/AboutControllerCest.php +++ b/tests/acceptance/controllers/AboutControllerCest.php @@ -1,4 +1,5 @@ '', + $emptyData = []; + $emptyPasswordData = [ + self::PASS_KEY => '', self::CONFIRM_PASS_KEY => '', ]; - $shortPasswordData = [ - self::PASS_KEY => '123', + $shortPasswordData = [ + self::PASS_KEY => '123', self::CONFIRM_PASS_KEY => '123', ]; - $emptyConfirmPasswordData = [ + $emptyConfirmPasswordData = [ self::PASS_KEY => 'valid password empty config', ]; $missMatchConfigPasswordData = [ - self::PASS_KEY => '123456780', + self::PASS_KEY => '123456780', self::CONFIRM_PASS_KEY => '123456789', ]; - $correctData1 = [ - self::PASS_KEY => '12345678', + $correctData1 = [ + self::PASS_KEY => '12345678', self::CONFIRM_PASS_KEY => '12345678', ]; - $correctData2 = [ - self::PASS_KEY => 'valid password', + $correctData2 = [ + self::PASS_KEY => 'valid password', self::CONFIRM_PASS_KEY => 'valid password' ]; - $correctData3 = [ - self::PASS_KEY => '(*%^%$#@#$%^', + $correctData3 = [ + self::PASS_KEY => '(*%^%$#@#$%^', self::CONFIRM_PASS_KEY => '(*%^%$#@#$%^', ]; @@ -61,13 +62,13 @@ public function dataProvider(): array * @dataProvider dataProvider * * @param array $data - * @param int $errorsCount - * @param bool $expected + * @param int $errorsCount + * @param bool $expected */ public function testValidations(array $data, int $errorsCount, bool $expected): void { - $form = new ChangePasswordForm(); - $isValid = $form->isValid($data); + $form = new ChangePasswordForm(); + $isValid = $form->isValid($data); $messages = $form->getMessages(); $this->assertEquals($expected, $isValid); diff --git a/tests/functional/forms/ForgotPasswordFormTest.php b/tests/functional/forms/ForgotPasswordFormTest.php index 9533f2f7..1a0c21e0 100644 --- a/tests/functional/forms/ForgotPasswordFormTest.php +++ b/tests/functional/forms/ForgotPasswordFormTest.php @@ -1,4 +1,5 @@ isValid($data); + $form = new ForgotPasswordForm(); + $isValid = $form->isValid($data); $messages = $form->getMessages(); $this->assertEquals($expected, $isValid); diff --git a/tests/functional/forms/LoginFormTest.php b/tests/functional/forms/LoginFormTest.php index dc88c37c..d526e196 100644 --- a/tests/functional/forms/LoginFormTest.php +++ b/tests/functional/forms/LoginFormTest.php @@ -1,35 +1,34 @@ register($di); - $emptyData = []; + $emptyData = []; $incorrectCsrfData = [ self::EMAIL_KEY => 'bob@phalcon.io', - self::PASS_KEY => 'password1', - self::CSRF_KEY => 'invalid', + self::PASS_KEY => 'password1', + self::CSRF_KEY => 'invalid', ]; return [ @@ -42,13 +41,13 @@ public function dataProvider(): array * @dataProvider dataProvider * * @param array $data - * @param int $errorsCount - * @param bool $expected + * @param int $errorsCount + * @param bool $expected */ public function testValidations(array $data, int $errorsCount, bool $expected): void { - $form = new LoginForm(); - $isValid = $form->isValid($data); + $form = new LoginForm(); + $isValid = $form->isValid($data); $messages = $form->getMessages(); $this->assertEquals($expected, $isValid); diff --git a/tests/functional/forms/ProfilesFormTest.php b/tests/functional/forms/ProfilesFormTest.php index 2df5ad8a..801ff55c 100644 --- a/tests/functional/forms/ProfilesFormTest.php +++ b/tests/functional/forms/ProfilesFormTest.php @@ -1,4 +1,5 @@ isValid($data); + $form = new ProfilesForm(); + $isValid = $form->isValid($data); $messages = $form->getMessages(); $this->assertEquals($expected, $isValid); diff --git a/tests/unit/ApplicationTest.php b/tests/unit/ApplicationTest.php index 924d20c2..46296dd3 100644 --- a/tests/unit/ApplicationTest.php +++ b/tests/unit/ApplicationTest.php @@ -1,4 +1,5 @@ constructEmptyExcept(Application::class, 'getRootPath', ['rootPath' => $rootPath]); + $class = $this->constructEmptyExcept(Application::class, 'getRootPath', ['rootPath' => $rootPath]); $this->assertEquals($rootPath, $class->getRootPath()); } diff --git a/tests/unit/controllers/AboutControllerTest.php b/tests/unit/controllers/AboutControllerTest.php index 69adbc7b..1f4accb1 100644 --- a/tests/unit/controllers/AboutControllerTest.php +++ b/tests/unit/controllers/AboutControllerTest.php @@ -1,4 +1,5 @@ - {{ link_to(null, 'class': 'navbar-brand', 'Vökuró') }} + {{ tag.a(url('/'), 'Vökuró', ['class': 'navbar-brand']) }} - @@ -17,24 +23,25 @@ {%- for key, value in menus %} {% if value == dispatcher.getControllerName() %} {% else %} - + {% endif %} {%- endfor -%} diff --git a/themes/vokuro/profiles/search.volt b/themes/vokuro/profiles/search.volt index a08967e4..c12e985a 100644 --- a/themes/vokuro/profiles/search.volt +++ b/themes/vokuro/profiles/search.volt @@ -18,14 +18,14 @@ {% for profile in page.items %} - {{ profile['id'] }} - {{ profile['name'] }} - {{ profile['active'] == 'Y' ? 'Yes' : 'No' }} + {{ profile.id }} + {{ profile.name }} + {{ profile.active == 'Y' ? 'Yes' : 'No' }} - {{ link_to("profiles/edit/" ~ profile['id'], ' Edit', "class": "btn btn-sm btn-outline-warning") }} + {{ link_to("profiles/edit/" ~ profile.id, ' Edit', "class": "btn btn-sm btn-outline-warning") }} - {{ link_to("profiles/delete/" ~ profile['id'], ' Delete', "class": "btn btn-sm btn-outline-danger") }} + {{ link_to("profiles/delete/" ~ profile.id, ' Delete', "class": "btn btn-sm btn-outline-danger") }} {% else %}