Skip to content

Commit

Permalink
Merge pull request #15 from ludeus/master
Browse files Browse the repository at this point in the history
Remove deprecation warning from CakePHP 3.6
  • Loading branch information
HavokInspiration authored Apr 23, 2018
2 parents 3b9c4b6 + 5c53fca commit 8e2c42a
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- 7.2
- 7.1
- 7.0
- 5.5
- 5.6
- nightly

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ for your CakePHP website / applications.

## About the plugin versions

| CakePHP < 3.3.0 | CakePHP >= 3.3.0 |
| --------------- | ---------------- |
| Wrench 1.X | Wrench 2.X |
| PHP >= 5.4.16 | PHP >= 5.5.9 |
| Uses CakePHP DispatcherFilter mecanism | Uses CakePHP Middleware Stack and PSR-7 Request / Response implementation |
| CakePHP < 3.3.0 | CakePHP >= 3.3.0 | CakePHP >= 3.6.0 |
| --------------- | ---------------- | ---------------- |
| Wrench 1.X | Wrench 2.X | Wrench 3.X |
| PHP >= 5.4.16 | PHP >= 5.5.9 | PHP >= 5.6.0 |
| Uses CakePHP DispatcherFilter mecanism | Uses CakePHP Middleware Stack and PSR-7 Request / Response implementation | Uses CakePHP Middleware Stack and PSR-7 Request / Response implementation + no deprecation warning from CakePHP 3.6.X |

## Recommanded package

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"source": "https://github.com/HavokInspiration/wrench"
},
"require": {
"php": ">=5.5.9",
"cakephp/cakephp": "~3.3"
"php": ">=5.6.0",
"cakephp/cakephp": "~3.6"
},
"require-dev": {
"phpunit/phpunit": "<6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/MaintenanceMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MaintenanceMiddleware
*/
public function __construct($config = [])
{
$this->config($config);
$this->setConfig($config);
$mode = $this->_config['mode'];

if (is_array($mode)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Mode/Mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class Mode
*/
public function __construct($config = [])
{
$this->config($config);
$this->setConfig($config);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Mode/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class Redirect extends Mode
public function process(ServerRequestInterface $request, ResponseInterface $response)
{
$url = $this->_getUrl($request);
$headers = $this->config('headers');
$headers = $this->getConfig('headers');

return new RedirectResponse($url, $this->config('code'), $headers);
return new RedirectResponse($url, $this->getConfig('code'), $headers);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/Mode/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
namespace Wrench\Mode;

use Cake\Core\Configure;
use Cake\Http\RequestTransformer;
use Cake\Http\ResponseTransformer;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -75,8 +74,8 @@ public function process(ServerRequestInterface $request, ResponseInterface $resp

$viewConfig = $this->_config['view'] ?: [];
$view = new $className(
RequestTransformer::toCake($request),
ResponseTransformer::toCake($response),
$request,
$response,
null,
$viewConfig
);
Expand Down
12 changes: 6 additions & 6 deletions src/Template/Bake/mode.ctp → src/Template/Bake/mode.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%
{#
/**
* Copyright (c) Yves Piquel (http://www.havokinspiration.fr)
*
Expand All @@ -9,24 +9,24 @@
* @link http://github.com/HavokInspiration/wrench
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
%>
#}
<?php
namespace <%= $namespace %>\Maintenance\Mode;
namespace {{ namespace }}\Maintenance\Mode;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Wrench\Mode\Mode;
/**
* <%= $name %> Maintenance Mode
* {{ name }} Maintenance Mode
*/
class <%= $name %> extends Mode
class {{ name }} extends Mode
{
/**
* Array containing the default config value for your maintenance mode
* This value can be overridden when loading the mode
* You can access a config value using $this->config('configkey');
* You can access a config value using $this->getConfig('configkey');
*
* @see \Cake\Core\InstanceConfigTrait
*/
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Middleware/MaintenanceMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class MaintenanceMiddlewareTest extends TestCase
public function testMaintenanceModeFilterNoParams()
{
$middleware = new MaintenanceMiddleware();
$this->assertEquals('Wrench\Mode\Redirect', $middleware->config('mode.className'));
$this->assertEquals([], $middleware->config('mode.config'));
$this->assertEquals('Wrench\Mode\Redirect', $middleware->getConfig('mode.className'));
$this->assertEquals([], $middleware->getConfig('mode.config'));
$this->assertInstanceOf('Wrench\Mode\Redirect', $middleware->mode());
}

Expand All @@ -55,6 +55,6 @@ public function testMaintenanceModeFilterModeInstance()
'url' => 'http://example.com/maintenance/',
'headers' => []
];
$this->assertEquals($expected, $middleware->mode()->config());
$this->assertEquals($expected, $middleware->mode()->getConfig());
}
}
2 changes: 1 addition & 1 deletion tests/TestCase/Mode/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
namespace Wrench\Test\TestCase\Mode;

use Cake\Core\Configure;
use Cake\Http\Response;
use Cake\Http\ServerRequestFactory;
use Cake\TestSuite\TestCase;
use Wrench\Middleware\MaintenanceMiddleware;
use Zend\Diactoros\Response;

class OutputTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Mode/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Http\Response;
use Cake\Http\ServerRequestFactory;
use Cake\TestSuite\TestCase;
use Wrench\Middleware\MaintenanceMiddleware;
use Zend\Diactoros\Response;

class ViewTest extends TestCase
{
Expand Down
5 changes: 5 additions & 0 deletions tests/TestCase/Shell/Task/MaintenanceModeTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class MaintenanceModeTaskTest extends TestCase
public function setUp()
{
parent::setUp();

Plugin::load('WyriHaximus/TwigView', [
'bootstrap' => true,
]);

$this->_compareBasePath = Plugin::path('Wrench') . 'tests' . DS . 'comparisons' . DS . 'Maintenance' . DS . 'Mode' . DS;

$io = $this->getMockBuilder('Cake\Console\ConsoleIo')
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
define('ROOT', $root . DS . 'tests' . DS . 'test_app');
define('APP', ROOT . DS . 'App' . DS);
define('TMP', sys_get_temp_dir() . DS);
define('CACHE', TMP . 'cache' . DS);

Configure::write('debug', true);
Configure::write('App', [
Expand All @@ -44,6 +45,7 @@
]);

Configure::write('App', [
'encoding' => 'utf-8',
'namespace' => 'App',
'paths' => [
'plugins' => [APP . 'Plugin' . DS],
Expand Down
2 changes: 1 addition & 1 deletion tests/comparisons/Maintenance/Mode/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Example extends Mode
/**
* Array containing the default config value for your maintenance mode
* This value can be overridden when loading the mode
* You can access a config value using $this->config('configkey');
* You can access a config value using $this->getConfig('configkey');
*
* @see \Cake\Core\InstanceConfigTrait
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/comparisons/Maintenance/Mode/PluginExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PluginExample extends Mode
/**
* Array containing the default config value for your maintenance mode
* This value can be overridden when loading the mode
* You can access a config value using $this->config('configkey');
* You can access a config value using $this->getConfig('configkey');
*
* @see \Cake\Core\InstanceConfigTrait
*/
Expand Down

0 comments on commit 8e2c42a

Please sign in to comment.