Skip to content

Commit

Permalink
Merge pull request #53 from arusinowski/3.next-cake5
Browse files Browse the repository at this point in the history
3.next cake5
  • Loading branch information
skie authored May 23, 2023
2 parents 7c2c85e + 72f1033 commit cf3a212
Show file tree
Hide file tree
Showing 32 changed files with 456 additions and 254 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: CI

on:
push:

pull_request:
branches:
- '*'

jobs:
testsuite:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['8.1']
db-type: [sqlite, mysql, pgsql]
prefer-lowest: ['']

steps:
- name: Setup MySQL latest
if: matrix.db-type == 'mysql'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin

- name: Setup PostgreSQL latest
if: matrix.db-type == 'pgsql'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres

- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, apcu, sqlite, pdo_sqlite, pdo_${{ matrix.db-type }}, ${{ matrix.db-type }}
ini-values: apc.enable_cli = 1
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

- name: composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer update
fi
- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '7.4' && matrix.db-type == 'mysql'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
run: |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp?encoding=utf8'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
- name: Submit code coverage
if: matrix.php-version == '7.4'
uses: codecov/codecov-action@v1

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl, apcu
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

- name: composer install
run: composer stan-setup

- name: Run PHP CodeSniffer
run: composer cs-check

# - name: Run psalm
# if: success() || failure()
# run: vendor/bin/psalm.phar --output-format=github

- name: Run phpstan
if: success() || failure()
run: composer stan
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/composer.lock
/plugins
/vendor
/auth.json
/.ddev
/.idea
6 changes: 3 additions & 3 deletions .semver
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
:major: 1
:minor: 5
:patch: 0
:major: 2
:minor: 0
:patch: 4
:special: ''
:metadata: ''
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

* 3.0.0-dev CakePHP 5.x support

* 2.0.0 CakePHP 4.x support

* 1.2.0
* Documentation improved
* Allow saving entity with no value for enum field
Expand Down
10 changes: 3 additions & 7 deletions Docs/Documentation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Composer

```
composer require cakedc/enum:dev-master
composer require cakedc/enum:3.0.0-dev
```

## Creating Required Tables
Expand All @@ -16,12 +16,8 @@ bin/cake migrations migrate -p CakeDC/Enum

## Load the Plugin

Ensure the Enum Plugin is loaded in your config/bootstrap.php file
Ensure the Enum Plugin is loaded in your `Application::bootstrap()` method:

```php
Plugin::load('CakeDC/Enum');
$this->addPlugin('CakeDC/Enum');
```
or
```php
Plugin::loadAll();
```
4 changes: 2 additions & 2 deletions Docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Home
Requirements
------------

* CakePHP 3.1+
* PHP 5.4.16+ Note CakePHP 3.2 requires PHP 5.5 so 5.4 compatibility would be dropped sooner than later...
* CakePHP 5.0+
* PHP 8.1+

Documentation
-------------
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ CakeDC Enum Plugin
[![Total Downloads](https://img.shields.io/packagist/dt/cakedc/enum.svg?style=flat-square)](https://packagist.org/packages/cakedc/enum)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)

Enumeration list for [CakePHP 3](http://cakephp.org).
Enumeration list for [CakePHP 5](http://cakephp.org).

Versions and branches
---------------------

| CakePHP | CakeDC Enum Plugin | Tag | Notes |
| :-------------: | :------------------------: | :--: | :---- |
| ^3.7 | [master](https://github.com/cakedc/enum/tree/master) | 1.5.0 | stable |
| ^3.7 | [develop](https://github.com/cakedc/enum/tree/develop) | - | unstable |
| ^3.6 | [master](https://github.com/cakedc/enum/tree/1.4.0) | 1.4.0 | stable |
| 3.1 - 3.5 | | 1.3.0 | stable |
| CakePHP | CakeDC Enum Plugin | Tag | Notes |
|:-----------|:--------------------------------------------------------|:----------|:---------|
| ^5.0.0-dev | [3.next](https://github.com/cakedc/enum/tree/3next) | 3.0.0-dev | unstable |
| ^4.0 | [2.next](https://github.com/cakedc/enum/tree/2.next) | 2.0.4 | stable |
| ^3.7 | [master](https://github.com/cakedc/enum/tree/master) | 1.5.0 | stable |
| ^3.7 | [develop](https://github.com/cakedc/enum/tree/develop) | - | unstable |
| ^3.6 | [master](https://github.com/cakedc/enum/tree/1.4.0) | 1.4.0 | stable |
| 3.1 - 3.5 | | 1.3.0 | stable |


Install
Expand All @@ -25,7 +27,7 @@ Install
Using [Composer](http://getcomposer.org):

```
composer require cakedc/enum:1.5.0
composer require cakedc/enum:3.0.0-dev
```

You then need to load the plugin. You can use the shell command:
Expand All @@ -34,17 +36,17 @@ You then need to load the plugin. You can use the shell command:
bin/cake plugin load CakeDC/Enum
```

or by manually adding statement shown below to `bootstrap.php`:
or by manually adding statement shown below to `Application::bootstrap()` method:

```php
Plugin::load('CakeDC/Enum');
$this->addPlugin('CakeDC/Enum');
```

Requirements
------------

* CakePHP 3.7+
* PHP 5.6+
* CakePHP 5.0+
* PHP 8.1+

Documentation
-------------
Expand All @@ -66,6 +68,6 @@ This repository follows the [CakeDC Plugin Standard](http://cakedc.com/plugin-st
License
-------

Copyright 2015 - 2019 Cake Development Corporation (CakeDC). All rights reserved.
Copyright 2015 - 2023 Cake Development Corporation (CakeDC). All rights reserved.

Licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.0-dev
28 changes: 19 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cakedc/enum",
"description": "Enumeration list Plugin for CakePHP 3",
"description": "Enumeration list Plugin for CakePHP 5",
"type": "cakephp-plugin",
"keywords": [
"cakephp",
Expand All @@ -14,13 +14,15 @@
"source": "https://github.com/cakedc/enum"
},
"require": {
"php": ">=7.2.0",
"cakephp/cakephp": "^4.0.0"
"php": ">=8.1",
"cakephp/cakephp": "5.x-dev"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"vlucas/phpdotenv": "^3.3",
"cakephp/cakephp-codesniffer": "~4.0.0"
"phpunit/phpunit": "^9.5.19",
"cakephp/cakephp-codesniffer": "^5.0",
"cakephp/bake": "3.x-dev",
"cakephp/migrations": "4.x-dev",
"aura/intl": "^3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -38,7 +40,7 @@
"analyse": [
"@stan",
"@psalm"
],
],
"check": [
"@cs-check",
"@test",
Expand All @@ -49,8 +51,16 @@
"test": "phpunit --stderr",
"stan": "phpstan analyse src/",
"psalm": "php vendor/psalm/phar/psalm.phar --show-info=false src/ ",
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12.7 psalm/phar:~3.8.0 && mv composer.backup composer.json",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.4.11 && mv composer.backup composer.json",
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:0.12.94 psalm/phar:~4.9.2 && mv composer.backup composer.json",
"stan-rebuild-baseline": "phpstan analyse --configuration phpstan.neon --error-format baselineNeon src/ > phpstan-baseline.neon",
"psalm-rebuild-baseline": "php vendor/psalm/phar/psalm.phar --show-info=false --set-baseline=psalm-baseline.xml src/",
"rector": "rector process",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.11.2 && mv composer.backup composer.json",
"coverage-test": "phpunit --stderr --coverage-clover=clover.xml"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion config/Migrations/001_create_enum_lookups.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CreateEnumLookups extends AbstractMigration
*
* @return void
*/
public function change()
public function change(): void
{
$table = $this->table('enum_lookups');

Expand Down
45 changes: 17 additions & 28 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="./tests/bootstrap.php"
colors="true"
stopOnFailure="false"
>

<testsuites>
<testsuite name="Enum Test Cases">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector"
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>

<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="Enum Test Cases">
<directory>./tests/TestCase</directory>
</testsuite>
</testsuites>
<!-- Setup a listener for fixtures -->
<extensions>
<extension class="\Cake\TestSuite\Fixture\PHPUnitExtension"/>
</extensions>
<!-- Prevent coverage reports from looking in tests and vendors -->
</phpunit>
4 changes: 0 additions & 4 deletions rector.yml

This file was deleted.

Loading

0 comments on commit cf3a212

Please sign in to comment.