Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish repo and try PSR-14 #1

Merged
merged 38 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a91714a
Remove unused files
overclokk Aug 22, 2023
32b1aec
CS:FIX
overclokk Aug 22, 2023
0259cfb
Reun Rector against src folder
overclokk Aug 22, 2023
ec5701b
Reun Rector against tests folder
overclokk Aug 22, 2023
5f811ca
Polish all files to the new WF
overclokk Aug 26, 2023
e2b2e3f
Remove legacy _temp folder
overclokk Aug 26, 2023
e83aba4
Add test WF
overclokk Aug 26, 2023
3fbb24b
Update WF
overclokk Aug 26, 2023
c17cb68
Move Event folder content to the root directory
overclokk Aug 27, 2023
103b991
Introduce new implementation for PSR-14
overclokk Aug 27, 2023
a46b295
Move PSR-14 implementeation to its own files
overclokk Aug 27, 2023
80409b2
Update test
overclokk Aug 27, 2023
978d48b
Update integration tests and move old PSR to experiment folder
overclokk Aug 28, 2023
4cc2113
Psalm
overclokk Aug 29, 2023
7fb6eed
Refactor Subscribe, Improve Subscribe, Move PsrDispatcher, Introduce …
overclokk Sep 2, 2023
cbdcdcc
Introduce NullState and OrderedListenerProviderTestTrait.php
overclokk Sep 2, 2023
cbb576d
Introduce ListenerRegistryInterface
overclokk Sep 2, 2023
29119cd
Introduce tests/integration/ImplementationTest.php
overclokk Sep 2, 2023
befdacc
Update fles
overclokk Sep 3, 2023
e99522a
Should fix #2
overclokk Sep 3, 2023
fa8d45b
Update doc
overclokk Sep 3, 2023
e4e8306
Introduce lint and STA WF
overclokk Sep 3, 2023
4e44755
Rename OrderedListenerProvider to GlobalOrderedListenerProvider
overclokk Sep 3, 2023
17e3e3b
Add more implementation tests
overclokk Sep 4, 2023
0c21e8d
Add some docs
overclokk Sep 5, 2023
34e8ed1
Update integration test and add module
overclokk Sep 7, 2023
1b7424e
Removed unused NullListenerProvider.php
overclokk Sep 19, 2023
8ecc361
closes #3
overclokk Sep 19, 2023
8031b29
closes #4
overclokk Sep 19, 2023
893f24d
closes #5
overclokk Sep 19, 2023
a5ad7b2
Add some integration tests and rename EventDispatcher to GlobalDispat…
overclokk Sep 23, 2023
344a2be
moved deprecated methods to trait
overclokk Sep 23, 2023
9251654
introduced PropagationAwareTrait
overclokk Sep 24, 2023
63cc864
first Readme modification
overclokk Sep 24, 2023
51fb48a
Remove deprecated methods from tests
overclokk Sep 25, 2023
234a737
split behavior in GlobalDispatcher and add some integration tests
overclokk Sep 27, 2023
9d49157
Update Makefile
overclokk Oct 7, 2023
2c3d610
Update Readme.md
overclokk Oct 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Docker only
PROJECT_NAME="event"
PHP_VERSION="7.4"
WP_VERSION="6.0"

WP_PORT=8888
DB_PORT=8889
PMA_PORT=8890

# Docker and Codeception
DB_NAME="test"
DB_HOST="mysql"
DB_USER="root"
DB_PASSWORD="root"
6 changes: 6 additions & 0 deletions .docker/codecept
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Get project name from .env file
PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')

docker exec -w /var/www/html/wp-content/plugins/"${PROJECT_NAME}" "${PROJECT_NAME}"_test sh -c "vendor/bin/codecept ${*}"
6 changes: 6 additions & 0 deletions .docker/composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Get project name from .env file
PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')

docker-compose run -w /var/www/html/wp-content/plugins/"${PROJECT_NAME}" --rm wordpress sh -c "composer ${*}"
62 changes: 62 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: '3.7'
services:
wordpress:
build:
context: ./wordpress
args:
PHP_VERSION: ${PHP_VERSION}
WP_VERSION: ${WP_VERSION}
container_name: ${PROJECT_NAME:-wordpress}_test
restart: always
ports:
- ${WP_PORT}:80
environment:
WORDPRESS_DB_HOST: ${DB_HOST:-mysql}
WORDPRESS_DB_NAME: ${DB_NAME:-test}
WORDPRESS_DB_USER: ${DB_USER:-root}
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD:-root}
WORDPRESS_TABLE_PREFIX: ${TABLE_PREFIX:-wp_}
WORDPRESS_DEBUG: 1
volumes:
- ../:/var/www/html/wp-content/plugins/${PROJECT_NAME:-wordpress}
- ../tests/_output/:/var/www/html/wp-content/plugins/${PROJECT_NAME:-wordpress}/tests/_output/
- ./mu-plugins/:/var/www/html/wp-content/mu-plugins/
depends_on:
- mysql
networks:
integration_test_networks:

mysql:
image: mysql:${DB_VERSION:-5.7}
container_name: ${PROJECT_NAME:-wordpress}_mysql_test
restart: always
ports:
- ${DB_PORT}:3306
environment:
MYSQL_DATABASE: ${DB_NAME:-test}
#MYSQL_USER: ${DB_USER:-root}
MYSQL_PASSWORD: ${DB_PASSWORD:-root}
#MYSQL_RANDOM_ROOT_PASSWORD: '1'
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
networks:
- integration_test_networks

phpmyadmin:
depends_on:
- mysql
image: phpmyadmin/phpmyadmin:${PMA_VERSION:-latest}
container_name: ${PROJECT_NAME}_phpmyadmin_test
restart: always
ports:
- ${PMA_PORT}:80
environment:
# For max upload from PHPMYADMIN https://github.com/10up/wp-local-docker-v2/issues/40#issuecomment-719915040
UPLOAD_LIMIT: 1G
PMA_HOST: ${DB_HOST:-mysql}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
networks:
- integration_test_networks

networks:
integration_test_networks:
driver: bridge
39 changes: 39 additions & 0 deletions .docker/wordpress/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ARG PHP_VERSION
ARG WP_VERSION

FROM wordpress:${WP_VERSION}-php${PHP_VERSION}

# Install pcov for code coverage
RUN set -eux; \
pecl install pcov; \
docker-php-ext-enable pcov

# If you want to use xdebug, uncomment the following lines
# Install xdebug for code coverage
#RUN set -eux; \
# pecl install xdebug-3.1.4; \
# docker-php-ext-enable xdebug

# Set XDEBUG_MODE=coverage or xdebug.mode=coverage
#ENV XDEBUG_MODE=coverage

RUN set -eux; \
apt-get update && apt-get install -y \
git \
nano \
less # Needed for the WP-CLI \
rm -rf /var/lib/apt/lists/*

# Git add safe directory for the working directory


# Needed for Db driver
# https://github.com/Codeception/Codeception/issues/3605
RUN docker-php-ext-install \
pdo_mysql

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp
9 changes: 0 additions & 9 deletions .editorconfig

This file was deleted.

29 changes: 12 additions & 17 deletions .env
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
WP_ROOT_FOLDER="/tmp/wordpress"
TEST_SITE_WP_ADMIN_PATH="/wp-admin"
TEST_SITE_DB_NAME="test"
TEST_SITE_DB_HOST="localhost"
TEST_SITE_DB_USER="root"
TEST_SITE_DB_PASSWORD=""
TEST_SITE_TABLE_PREFIX="wp_"
TEST_DB_NAME="wploader"
TEST_DB_HOST="localhost"
TEST_DB_USER="root"
TEST_DB_PASSWORD=""
TEST_TABLE_PREFIX="wp_"
TEST_SITE_WP_URL="http://wp.localhost"
TEST_SITE_WP_DOMAIN="wp.localhost"
TEST_SITE_ADMIN_EMAIL="admin@wp.localhost"
TEST_SITE_ADMIN_USERNAME="admin"
TEST_SITE_ADMIN_PASSWORD="password"
# Codeception configuration file
ROOT_FOLDER="../../../"

DB_HOST="localhost"
DB_NAME="test"
DB_USER="root"
DB_PASSWORD="root"

TABLE_PREFIX="wp_"

DOMAIN="localhost"
ADMIN_EMAIL="admin@localhost.test"
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CS - File lint and file validation

on:
push:
pull_request:
paths:
- '**workflows/lint.yml'
- '**.php'
- '**phpcs.xml.dist'
- '**composer.json'

jobs:
lint:
name: ✔ CS check al files

runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '--skip ci') && !github.event.pull_request.draft"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Validate php files
run: find ./src/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l

- uses: ramsey/composer-install@v2

- name: Coding standard
run: composer run cs
31 changes: 31 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Static Analysis

on:
pull_request:
push:
paths:
- '**workflows/static-analysis.yml'
- '**.php'
- '**psalm.xml'
- '**composer.json'

jobs:
tests:
name: Static Analysis for PHP

runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '--skip ci') && !github.event.pull_request.draft"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- uses: ramsey/composer-install@v2

- name: Psalm
run: vendor/bin/psalm
94 changes: 94 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI

env:
PROJECT_KIND: plugins
DB_HOST: localhost
DB_NAME: test
DB_USER: root
DB_PASSWORD: root
TABLE_PREFIX: wp_
APP_FOLDER_PATH: /tmp/app
APP_PORT: 8888
APP_HOST: localhost
APP_USER: root
APP_PASSWORD: root

on:
workflow_dispatch:
pull_request:
push:
branches:
- master


jobs:

tests:
name: 🐘 Tests on PHP ${{matrix.php_versions}} & APP version ${{matrix.app_versions}}

strategy:
matrix:
php_versions: ['7.4']
app_versions: ['6.0']

runs-on: ubuntu-latest
continue-on-error: ${{ matrix.php_versions == '8.2' }}
if: "!contains(github.event.head_commit.message, '--skip ci') && !github.event.pull_request.draft"

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php_versions}}

- name: Start MySQL
run: |
sudo systemctl start mysql.service
mysql -e "CREATE DATABASE IF NOT EXISTS ${{env.DB_NAME}};" -u${{env.DB_USER}} -p${{env.DB_PASSWORD}}

- name: Install CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp cli info

- name: Create folder for running the App
run: mkdir -p ${{env.APP_FOLDER_PATH}}

- name: Install App
working-directory: ${{env.APP_FOLDER_PATH}}
run: |
wp core download --version="${{matrix.app_versions}}"
wp config create --dbname="${{env.DB_NAME}}" --dbuser="${{env.DB_USER}}" --dbpass="${{env.DB_PASSWORD}}" --dbhost="${{env.DB_HOST}}" --dbprefix="${{env.TABLE_PREFIX}}"
wp core install --url="${{env.APP_HOST}}:${{env.APP_PORT}}" --title="Test" --admin_user="${{env.APP_USER}}" --admin_password="${{env.APP_PASSWORD}}" --admin_email="${{env.APP_USER}}@${{env.APP_HOST}}.test" --skip-email
wp core update-db
cp -r $GITHUB_WORKSPACE ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{ github.event.repository.name }}

- uses: "ramsey/composer-install@v2"
with:
working-directory: "${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{ github.event.repository.name }}"

- name: Activate ${{ github.event.repository.name }}
working-directory: ${{env.APP_FOLDER_PATH}}
run: |
wp plugin deactivate --all
wp site empty --yes
wp plugin activate ${{ github.event.repository.name }}
wp plugin list --status=active
chmod -R 777 wp-content/${{env.PROJECT_KIND}}/${{ github.event.repository.name }}
ls -la wp-content/${{env.PROJECT_KIND}}/${{ github.event.repository.name }}
wp db export wp-content/${{env.PROJECT_KIND}}/${{ github.event.repository.name }}/tests/_data/dump.sql

- name: Build codeception
working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{ github.event.repository.name }}
run: ./vendor/bin/codecept build

- name: Run Unit & Integration test
working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{ github.event.repository.name }}
run: |
./vendor/bin/codecept run unit --coverage-text
./vendor/bin/codecept run integration
composer bench
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Composer
/vendor/

/_others/
# Codeception
codeception.yml

# Rector
rector.php

# Common File
*.local
codeception.yml
*.lock

c3.php
infection.log
infection-log.txt
infection.json
*.phar
Loading
Loading