Skip to content

Commit

Permalink
Merge pull request #50 from robertpustulka/cake5
Browse files Browse the repository at this point in the history
CakePHP 5 upgrade
  • Loading branch information
jeremyharris authored Jan 9, 2024
2 parents fcb038b + 3295115 commit cc775bc
Show file tree
Hide file tree
Showing 22 changed files with 344 additions and 392 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci

on: [push]

jobs:
testsuite:
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl-72.1
ini-values: zend.assertions = 1

- name: Install composer dependencies.
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Run PHPUnit.
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.phpunit.cache/
vendor/
composer.lock
62 changes: 0 additions & 62 deletions .travis.yml

This file was deleted.

26 changes: 16 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,30 @@
}
],
"require": {
"cakephp/orm": "~4.0",
"php": ">=7.2",
"php-coveralls/php-coveralls": "^2.0"
"php": "^8.1",
"cakephp/orm": "^5.0"
},
"require-dev": {
"cakephp/cakephp": "~4.0",
"phpunit/phpunit": "^8",
"cakephp/cakephp-codesniffer": "dev-master"
"cakephp/cakephp": "^5.0",
"cakephp/cakephp-codesniffer": "^5.1",
"php-coveralls/php-coveralls": "^0.4.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
"Josegonzalez\\Version\\": "src",
"Josegonzalez\\Version\\Test\\Fixture\\": "tests\\Fixture"
"Josegonzalez\\Version\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Josegonzalez\\Version\\Test\\": "tests"
"Josegonzalez\\Version\\Test\\": "tests/"
}
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
6 changes: 0 additions & 6 deletions config/bootstrap.php

This file was deleted.

8 changes: 0 additions & 8 deletions config/bootstrap_cli.php

This file was deleted.

4 changes: 4 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<ruleset name="App">
<rule ref="./vendor/cakephp/cakephp-codesniffer/CakePHP/ruleset.xml"/>
</ruleset>
45 changes: 19 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?><phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>
<?xml version="1.0" encoding="UTF-8"?>
<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/10.3/phpunit.xsd"
cacheDirectory=".phpunit.cache">

<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>

<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="Version Test Suite">
<directory>./tests/TestCase</directory>
<testsuite name="Version">
<directory>tests/TestCase/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./tests</directory>
</whitelist>
</filter>

<!-- 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>
<extensions>
<bootstrap class="\Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
</extensions>

<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
20 changes: 10 additions & 10 deletions src/Event/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Josegonzalez\Version\Event;

use Cake\Event\Event as CakeEvent;
use Cake\Event\EventDispatcherTrait;
use Cake\Event\EventInterface;
use Cake\Event\EventListenerInterface;

/**
Expand All @@ -31,18 +31,18 @@ abstract class EventListener implements EventListenerInterface
use EventDispatcherTrait;

/**
* The CakeEvent attached to this class
* The EventInterface attached to this class
*
* @var \Cake\Event\Event $event Event instance.
* @var \Cake\Event\EventInterface $event Event instance.
*/
protected $event;
protected EventInterface $event;

/**
* Constructor.
*
* @param \Cake\Event\Event $event Event instance.
* @param \Cake\Event\EventInterface $event Event instance.
*/
public function __construct(CakeEvent $event)
public function __construct(EventInterface $event)
{
$this->event = $event;
$this->getEventManager()->on($this);
Expand All @@ -53,21 +53,21 @@ public function __construct(CakeEvent $event)
*
* @return void
*/
public function execute()
public function execute(): void
{
$methods = array_values($this->implementedEvents());
foreach ($methods as $method) {
$this->dispatchEvent(sprintf('Bake.%s', $method), null, $this->event->subject);
$this->dispatchEvent(sprintf('Bake.%s', $method), [], $this->event->getSubject());
}
}

/**
* Check whether or not a bake call is a certain type.
*
* @param string|array $type The type of file you want to check.
* @param string $type The type of file you want to check.
* @return bool Whether or not the bake template is the type you are checking.
*/
public function isType($type)
public function isType(string $type): bool
{
$template = sprintf('Bake/%s.ctp', $type);

Expand Down
Loading

0 comments on commit cc775bc

Please sign in to comment.