Skip to content

Commit

Permalink
removed copyright from tests/bootstrap.php, updated CakePHP dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
arusinowski committed Sep 4, 2023
1 parent de52512 commit a75c66b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- cake5
pull_request:
branches:
- '*'
Expand Down
16 changes: 15 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"source": "https://github.com/usemuffin/throttle"
},
"require": {
"cakephp/cakephp": "5.0.0-RC2"
"cakephp/cakephp": "5.x-dev"
},
"require-dev": {
"phpunit/phpunit": "^10.1.0",
Expand All @@ -60,5 +60,19 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"cs-check": "phpcs --colors --parallel=16 -p src/ tests/",
"cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/",
"phpstan": "tools/phpstan analyse",
"psalm": "tools/psalm --show-info=false",
"stan": [
"@phpstan",
"@psalm"
],
"stan-baseline": "tools/phpstan --generate-baseline",
"psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml",
"stan-setup": "phive install",
"test": "phpunit"
}
}
6 changes: 6 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<ruleset name="Single Table Inheritance for CakePHP ORM">
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />

<rule ref="CakePHP" />
</ruleset>
12 changes: 10 additions & 2 deletions src/Middleware/ThrottleMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;

/**
* ThrottleMiddleware
*
* @implements \Cake\Event\EventDispatcherInterface<\Muffin\Throttle\Middleware\ThrottleMiddleware>
*/
class ThrottleMiddleware implements MiddlewareInterface, EventDispatcherInterface
{
use InstanceConfigTrait;

/**
* @use \Cake\Event\EventDispatcherTrait<\Muffin\Throttle\Middleware\ThrottleMiddleware>
*/
use EventDispatcherTrait;

public const EVENT_BEFORE_THROTTLE = 'Throttle.beforeThrottle';
Expand Down Expand Up @@ -248,8 +257,7 @@ protected function _initCache(): void
protected function _getDefaultCacheConfigClassName(): string
{
$config = Cache::getConfig('default');
$engine = (string)$config['className'];

$engine = $config ? (string)$config['className'] ?? '' : '';
// short cache engine names can be returned immediately
if (!str_contains($engine, '\\')) {
return $engine;
Expand Down
19 changes: 7 additions & 12 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
declare(strict_types=1);

/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* Test suite bootstrap.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://www.opensource.org/licenses/mit-license.php MIT License
* This function is used to find the location of CakePHP whether CakePHP
* has been installed as a dependency of the plugin, or the plugin is itself
* installed as a dependency of an application.
*/

use Cake\Cache\Cache;
Expand Down Expand Up @@ -50,7 +46,7 @@

Configure::write('debug', true);
Configure::write('App', [
'namespace' => 'DebugKit\TestApp',
'namespace' => 'Muffin\Throttle',
'encoding' => 'UTF-8',
'base' => false,
'baseUrl' => false,
Expand Down Expand Up @@ -90,15 +86,14 @@

// Ensure default test connection is defined
if (!getenv('DB_URL')) {
putenv('DB_URL=sqlite://127.0.0.1/' . TMP . 'debug_kit_test.sqlite');
putenv('DB_URL=sqlite://127.0.0.1/' . TMP . 'test.sqlite');
}

$config = [
'url' => getenv('DB_URL'),
'timezone' => 'UTC',
];

// Use the test connection for 'debug_kit' as well.
ConnectionManager::setConfig('test', $config);

Log::setConfig([
Expand All @@ -121,5 +116,5 @@
// Create test database schema
if (env('FIXTURE_SCHEMA_METADATA')) {
$loader = new SchemaLoader();
$loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA'), 'test');
$loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA'));
}

0 comments on commit a75c66b

Please sign in to comment.