浏览代码

Fix up for CakePHP 4.3

mscherer 4 年之前
父节点
当前提交
3878dd3ee6
共有 4 个文件被更改,包括 22 次插入21 次删除
  1. 7 8
      .github/workflows/ci.yml
  2. 2 2
      README.md
  3. 8 6
      composer.json
  4. 5 5
      tests/TestCase/Utility/FileLogTest.php

+ 7 - 8
.github/workflows/ci.yml

@@ -7,15 +7,15 @@ on:
 
 jobs:
   testsuite:
-    runs-on: ubuntu-18.04
+    runs-on: ubuntu-20.04
     strategy:
       fail-fast: false
       matrix:
-        php-version: ['7.2', '8.0']
+        php-version: ['7.3', '8.0']
         db-type: [sqlite, mysql, pgsql]
         prefer-lowest: ['']
         include:
-          - php-version: '7.2'
+          - php-version: '7.3'
             db-type: 'sqlite'
             prefer-lowest: 'prefer-lowest'
 
@@ -57,21 +57,20 @@ jobs:
     - name: Composer install --no-progress --prefer-dist --optimize-autoloader
       run: |
         composer --version
-        composer require --dev phpunit/phpunit:"^8.5||^9.5"
         if ${{ matrix.prefer-lowest == 'prefer-lowest' }}
         then
           composer update --prefer-lowest --prefer-stable
         else
           composer install --no-progress --prefer-dist --optimize-autoloader
         fi
-        if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then composer require --dev dereuromark/composer-prefer-lowest:dev-master; fi
+        if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then composer lowest-setup; fi
 
     - 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:root@127.0.0.1/cakephp'; fi
         if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi
-        if [[ ${{ matrix.php-version }} == '7.2' && ${{ matrix.db-type }} == 'sqlite' ]]; then
+        if [[ ${{ matrix.php-version }} == '7.3' && ${{ matrix.db-type }} == 'sqlite' ]]; then
           vendor/bin/phpunit --coverage-clover=coverage.xml
         else
           vendor/bin/phpunit
@@ -81,12 +80,12 @@ jobs:
       run: if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then vendor/bin/validate-prefer-lowest -m; fi
 
     - name: Code Coverage Report
-      if: success() && matrix.php-version == '7.2' && matrix.db-type == 'sqlite'
+      if: success() && matrix.php-version == '7.3' && matrix.db-type == 'sqlite'
       uses: codecov/codecov-action@v1
 
   validation:
     name: Coding Standard & Static Analysis
-    runs-on: ubuntu-18.04
+    runs-on: ubuntu-20.04
 
     steps:
     - uses: actions/checkout@v2

+ 2 - 2
README.md

@@ -2,7 +2,7 @@
 [![CI](https://github.com/dereuromark/cakephp-tools/workflows/CI/badge.svg?branch=master)](https://github.com/dereuromark/cakephp-tools/actions?query=workflow%3ACI+branch%3Amaster)
 [![Coverage Status](https://img.shields.io/codecov/c/github/dereuromark/cakephp-tools/master.svg)](https://codecov.io/gh/dereuromark/cakephp-tools)
 [![Latest Stable Version](https://poser.pugx.org/dereuromark/cakephp-tools/v/stable.svg)](https://packagist.org/packages/dereuromark/cakephp-tools)
-[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)](https://php.net/)
+[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg)](https://php.net/)
 [![License](https://poser.pugx.org/dereuromark/cakephp-tools/license.svg)](https://packagist.org/packages/dereuromark/cakephp-tools)
 [![Total Downloads](https://poser.pugx.org/dereuromark/cakephp-tools/d/total.svg)](https://packagist.org/packages/dereuromark/cakephp-tools)
 [![Coding Standards](https://img.shields.io/badge/cs-PSR--2--R-yellow.svg)](https://github.com/php-fig-rectified/fig-rectified-standards)
@@ -11,7 +11,7 @@ A CakePHP plugin containing several useful tools that can be used in many projec
 
 ## Version notice
 
-This master branch only works for **CakePHP 4.0+**. See [version map](https://github.com/dereuromark/cakephp-tools/wiki#cakephp-version-map) for details.
+This master branch only works for **CakePHP 4.2+**. See [version map](https://github.com/dereuromark/cakephp-tools/wiki#cakephp-version-map) for details.
 
 ## What is this plugin for?
 

+ 8 - 6
composer.json

@@ -13,15 +13,16 @@
 		}
 	],
 	"require": {
-		"php": ">=7.2",
-		"cakephp/cakephp": "^4.1",
+		"php": ">=7.3",
+		"cakephp/cakephp": "^4.2.0",
 		"dereuromark/cakephp-shim": "^2.0.0"
 	},
 	"require-dev": {
 		"cakephp/chronos": "^2.0",
 		"mobiledetect/mobiledetectlib": "^2.8",
 		"fig-r/psr2r-sniffer": "dev-master",
-		"yangqi/htmldom": "^1.0"
+		"yangqi/htmldom": "^1.0",
+		"phpunit/phpunit": "^9.5"
 	},
 	"autoload": {
 		"psr-4": {
@@ -47,9 +48,10 @@
 	"scripts": {
 		"stan": "phpstan analyse",
 		"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12.1 && mv composer.backup composer.json",
-		"test": "php phpunit.phar",
-		"test-setup": "[ ! -f phpunit.phar ] && wget https://phar.phpunit.de/phpunit-8.5.1.phar && mv phpunit-8.5.1.phar phpunit.phar || true",
-		"test-coverage": "php phpunit.phar --log-junit webroot/coverage/unitreport.xml --coverage-html webroot/coverage --coverage-clover webroot/coverage/coverage.xml",
+		"test": "phpunit",
+		"test-coverage": "phpunit --log-junit webroot/coverage/unitreport.xml --coverage-html webroot/coverage --coverage-clover webroot/coverage/coverage.xml",
+		"lowest": "validate-prefer-lowest",
+		"lowest-setup": "composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction && cp composer.json composer.backup && composer require --dev dereuromark/composer-prefer-lowest && mv composer.backup composer.json",
 		"cs-check": "phpcs -p -s --standard=vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml --extensions=php --ignore=/config/Migrations/,/tests/test_files/ src/ tests/ config/",
 		"cs-fix": "phpcbf -p --standard=vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml --extensions=php --ignore=/config/Migrations/,/tests/test_files/ src/ tests/ config/"
 	},

+ 5 - 5
tests/TestCase/Utility/FileLogTest.php

@@ -68,7 +68,7 @@ class FileLogTest extends TestCase {
 		$this->assertTrue($result);
 		$this->assertFileExists(static::TEST_FILEPATH_STRING);
 		$this->assertRegExp(
-			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: It works!/',
+			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: It works!/i',
 			file_get_contents(static::TEST_FILEPATH_STRING)
 		);
 
@@ -115,7 +115,7 @@ class FileLogTest extends TestCase {
 		$this->assertFileExists(static::TEST_FILEPATH_ARRAY1);
 		$fileContents = file_get_contents(static::TEST_FILEPATH_ARRAY1);
 		$this->assertRegExp(
-			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: Array([\s\S]*)\(([\s\S]*)[user]([\s\S]*)\[id\] => 1/',
+			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: Array([\s\S]*)\(([\s\S]*)[user]([\s\S]*)\[id\] => 1/i',
 			$fileContents
 		);
 
@@ -124,7 +124,7 @@ class FileLogTest extends TestCase {
 		$this->assertFileExists(static::TEST_FILEPATH_ARRAY2);
 		$fileContents = file_get_contents(static::TEST_FILEPATH_ARRAY2);
 		$this->assertRegExp(
-			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: Array([\s\S]*)\(([\s\S]*)[user]([\s\S]*)\[id\] => 2/',
+			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: Array([\s\S]*)\(([\s\S]*)[user]([\s\S]*)\[id\] => 2/i',
 			$fileContents
 		);
 
@@ -150,7 +150,7 @@ class FileLogTest extends TestCase {
 		$this->assertTrue($result);
 		$this->assertFileExists(static::TEST_FILEPATH_OBJECT);
 		$this->assertRegExp(
-			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: TestApp.Model.Table.PostsTable Object/',
+			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: TestApp.Model.Table.PostsTable Object/i',
 			file_get_contents(static::TEST_FILEPATH_OBJECT)
 		);
 
@@ -172,7 +172,7 @@ class FileLogTest extends TestCase {
 		$this->assertTrue($result);
 		$this->assertFileExists(static::TEST_DEFAULT_FILEPATH_STRING);
 		$this->assertRegExp(
-			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: It works with default too!/',
+			'/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: It works with default too!/i',
 			file_get_contents(static::TEST_DEFAULT_FILEPATH_STRING)
 		);