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

Cake 5 updates #386

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 7 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,17 @@ on:
branches:
- '*'

permissions:
contents: read

jobs:
testsuite:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2']
prefer-lowest: ['']
include:
- php-version: '8.1'
prefer-lowest: 'prefer-lowest'

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: pcov

- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
elif ${{ matrix.php-version == '8.2' }}; then
composer update --ignore-platform-req=php
else
composer update
fi

- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '8.1'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
continue-on-error: ${{ matrix.prefer-lowest == 'prefer-lowest' }}

- name: Code Coverage Report
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v3
uses: cakephp/.github/.github/workflows/[email protected]
secrets: inherit

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

steps:
- uses: actions/checkout@v3
Expand All @@ -78,7 +29,7 @@ jobs:
php-version: '8.1'
extensions: mbstring, intl
coverage: none
tools: cs2pr, vimeo/psalm:4.23, phpstan:1.7
tools: cs2pr, vimeo/psalm:5, phpstan:1.10

- name: Composer Install
run: composer install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ vendor/
composer.lock
node_modules
.phpunit.result.cache
.phpunit.cache

# Generated test files
tests/test_app/webroot/bootstrap_u_i
Expand Down
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
}
],
"require": {
"cakephp/cakephp": "5.x-dev"
"cakephp/cakephp": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5.19",
"cakephp/bake": "dev-cake5",
"cakephp/cakephp-codesniffer": "5.x-dev"
"phpunit/phpunit": "^10.1",
"cakephp/bake": "^3.0",
"cakephp/cakephp-codesniffer": "^5.0"
},
"support": {
"issues": "http://github.com/friendsofcake/bootstrap-ui/issues",
Expand Down Expand Up @@ -52,7 +52,5 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
23 changes: 8 additions & 15 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="bootstrap">
<directory>tests/TestCase/</directory>
<exclude>tests/TestCase/View/Helper/FormHelper/AbstractFormHelperTest.php</exclude>
</testsuite>
</testsuites>

<extensions>
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension"/>
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
</extensions>

<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>

<php>
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
autoloader="tests/bootstrap.php"
findUnusedBaselineEntry="false"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
Expand Down
2 changes: 2 additions & 0 deletions src/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Cake\View\Helper\FormHelper as CoreFormHelper;
use Cake\View\View;
use InvalidArgumentException;
use function Cake\Core\h;
use function Cake\I18n\__;

class FormHelper extends CoreFormHelper
{
Expand Down
1 change: 1 addition & 0 deletions src/View/Helper/PaginatorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Cake\View\Helper\PaginatorHelper as CorePaginatorHelper;
use Cake\View\View;
use function Cake\Core\h;

class PaginatorHelper extends CorePaginatorHelper
{
Expand Down
1 change: 1 addition & 0 deletions templates/element/flash/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @var array $params
* @var string $message
*/
use function Cake\Core\h;

$icon = $params['icon'];
$class = array_unique((array)$params['class']);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Helper/FlashHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function tearDown(): void
unset($this->View, $this->Flash);
}

public function flashTypeDefaultsDataProvider(): array
public static function flashTypeDefaultsDataProvider(): array
{
return [
['default', 'info', 'info-circle-fill'],
Expand Down Expand Up @@ -433,7 +433,7 @@ public function testCustomHtmlIcon()
$this->assertHtml($expected, $result, true);
}

public function flashTypeDataProvider(): array
public static function flashTypeDataProvider(): array
{
return [
['default'],
Expand Down
10 changes: 5 additions & 5 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@
],
]);

if (!getenv('db_dsn')) {
putenv('db_dsn=sqlite:///:memory:');
if (!getenv('DB_URL')) {
putenv('DB_URL=sqlite:///:memory:');
}
ConnectionManager::setConfig('test', ['url' => getenv('db_dsn')]);
ConnectionManager::setConfig('test', ['url' => getenv('DB_URL')]);

Plugin::getCollection()->add(new BootstrapUIPlugin(['path' => ROOT . DS]));
Plugin::getCollection()->add(new BakePlugin());

// Create test database schema
if (env('FIXTURE_SCHEMA_METADATA')) {
if (getenv('FIXTURE_SCHEMA_METADATA')) {
$loader = new SchemaLoader();
$loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA'));
$loader->loadInternalFile(getenv('FIXTURE_SCHEMA_METADATA'));
}