Skip to content

Commit

Permalink
Merge pull request #139 from FriendsOfCake/5.x-update
Browse files Browse the repository at this point in the history
Bump up to CakePHP 5 stable.
  • Loading branch information
ADmad authored Oct 13, 2023
2 parents 0cf63fa + cfec296 commit c2e539c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ phpstan-baseline.neon export-ignore
phpunit.xml.dist export-ignore
psalm.xml export-ignore
psalm-baseline.xml export-ignore
.phive export-ignore
5 changes: 5 additions & 0 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.10.38" installed="1.10.38" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.15.0" installed="5.15.0" location="./tools/psalm" copy="false"/>
</phive>
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ scope in your app's `routes.php`.
```php
// PostsController.php

// Override the viewClasses method of your controller:
public function viewClasses()
// Add the CsvView class for content type negotiation
public function initialize(): void
{
return ['csv' => 'CsvView.Csv'];
parent::initialize();

$this->addViewClasses(['csv' => 'CsvView.Csv']);
}

// Controller action
Expand Down
9 changes: 3 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@
}
],
"require": {
"php": ">=8.1",
"cakephp/cakephp": "5.x-dev"
"cakephp/cakephp": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5.0",
"phpunit/phpunit": "^10.1",
"cakephp/cakephp-codesniffer": "^5.0"
},
"autoload": {
Expand Down Expand Up @@ -85,7 +84,5 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
22 changes: 8 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">

<!-- Add any additional test suites you want to run here -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd">
<testsuites>
<testsuite name="csv-view">
<directory>tests/TestCase/</directory>
<directory>tests/TestCase/</directory>
</testsuite>
</testsuites>

<!-- Setup a listener for fixtures -->
<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: 1 addition & 1 deletion tests/TestCase/View/CsvViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public function testPassingQueryAsData()
$output = $this->view->render();

$articles->belongsTo('Authors');
$query = $articles->find('all', ['contain' => 'Authors']);
$query = $articles->find('all', contain: 'Authors');
$_extract = ['title', 'body', 'author.name'];
$this->view->set(['data' => $query])
->setConfig(['extract' => $_extract, 'serialize' => 'data']);
Expand Down
7 changes: 4 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
declare(strict_types=1);

use Cake\Core\Configure;
use Cake\TestSuite\Fixture\SchemaLoader;

/**
* Test suite bootstrap
Expand Down Expand Up @@ -43,7 +44,7 @@
],
]);

if (env('FIXTURE_SCHEMA_METADATA')) {
$loader = new Cake\TestSuite\Fixture\SchemaLoader();
$loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA'));
if (getenv('FIXTURE_SCHEMA_METADATA')) {
$loader = new SchemaLoader();
$loader->loadInternalFile(getenv('FIXTURE_SCHEMA_METADATA'));
}

0 comments on commit c2e539c

Please sign in to comment.