Skip to content

Commit

Permalink
Merge pull request #381 from cakephp/master-deprecations
Browse files Browse the repository at this point in the history
Remove deprecations
  • Loading branch information
dereuromark authored Dec 25, 2018
2 parents b5ed95f + 7ea19c8 commit b514818
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
*.mo
debug.log
error.log
/tests/test_app/config/Create/*
/tests/test_app/config/Migrations/*
/tests/test_app/config/TestsMigrations/schema-dump-test.lock
/tests/test_app/Plugin/TestBlog/config/Migrations/*

# IDE and editor specific files #
#################################
Expand Down
4 changes: 2 additions & 2 deletions src/ConfigurationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
namespace Migrations;

use Cake\Core\Plugin;
use Cake\Core\Plugin as CorePlugin;
use Cake\Datasource\ConnectionManager;
use Migrations\Util\UtilTrait;
use Phinx\Config\Config;
Expand Down Expand Up @@ -81,7 +81,7 @@ public function getConfig($forceRefresh = false)
$connectionConfig = ConnectionManager::getConfig($connection);
$adapterName = $this->getAdapterName($connectionConfig['driver']);

$templatePath = Plugin::path('Migrations') . 'src' . DS . 'Template' . DS;
$templatePath = CorePlugin::path('Migrations') . 'src' . DS . 'Template' . DS;
$config = [
'paths' => [
'migrations' => $migrationsPath,
Expand Down
34 changes: 34 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Migrations;

use Cake\Core\BasePlugin;

/**
* Plugin class for migrations
*/
class Plugin extends BasePlugin
{
/**
* Plugin name.
*
* @var string
*/
protected $name = 'Migrations';

/**
* Don't try to load routes.
*
* @var bool
*/
protected $routesEnabled = false;
}
6 changes: 3 additions & 3 deletions src/Shell/Task/SeedTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Bake\Shell\Task\SimpleBakeTask;
use Cake\Console\ConsoleOptionParser;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Core\Plugin as CorePlugin;
use Cake\Datasource\ConnectionManager;
use Cake\Utility\Inflector;

Expand Down Expand Up @@ -141,8 +141,8 @@ public function getOptionParser()
$parser = new ConsoleOptionParser($name);

$bakeThemes = [];
foreach (Plugin::loaded() as $plugin) {
$path = Plugin::classPath($plugin);
foreach (CorePlugin::loaded() as $plugin) {
$path = CorePlugin::classPath($plugin);
if (is_dir($path . 'Template' . DS . 'Bake')) {
$bakeThemes[] = $plugin;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Shell/Task/SimpleMigrationTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Bake\Shell\Task\SimpleBakeTask;
use Cake\Console\ConsoleOptionParser;
use Cake\Core\Plugin;
use Cake\Core\Plugin as CorePlugin;
use Cake\Utility\Inflector;
use Phinx\Util\Util;

Expand Down Expand Up @@ -130,8 +130,8 @@ public function getOptionParser()
$parser = new ConsoleOptionParser($name);

$bakeThemes = [];
foreach (Plugin::loaded() as $plugin) {
$path = Plugin::classPath($plugin);
foreach (CorePlugin::loaded() as $plugin) {
$path = CorePlugin::classPath($plugin);
if (is_dir($path . 'Template' . DS . 'Bake')) {
$bakeThemes[] = $plugin;
}
Expand Down
6 changes: 3 additions & 3 deletions src/TableFinderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Migrations;

use Cake\Core\App;
use Cake\Core\Plugin;
use Cake\Core\Plugin as CorePlugin;
use Cake\Database\Schema\Collection;
use Cake\Datasource\ConnectionManager;
use Cake\Filesystem\Folder;
Expand Down Expand Up @@ -97,7 +97,7 @@ protected function getTablesToBake(Collection $collection, $options = [])
*/
protected function getTableNames($pluginName = null)
{
if ($pluginName !== null && !Plugin::isLoaded($pluginName)) {
if ($pluginName !== null && !CorePlugin::getCollection()->has($pluginName)) {
return [];
}
$list = [];
Expand All @@ -124,7 +124,7 @@ protected function findTables($pluginName = null)
{
$path = 'Model' . DS . 'Table' . DS;
if ($pluginName) {
$path = Plugin::path($pluginName) . 'src' . DS . $path;
$path = CorePlugin::path($pluginName) . 'src' . DS . $path;
} else {
$path = APP . $path;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Util/UtilTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
namespace Migrations\Util;

use Cake\Core\Plugin;
use Cake\Core\Plugin as CorePlugin;
use Cake\Utility\Inflector;
use Symfony\Component\Console\Input\InputInterface;

Expand Down Expand Up @@ -73,7 +73,7 @@ protected function getOperationsPath(InputInterface $input, $default = 'Migratio
$plugin = $this->getPlugin($input);

if ($plugin !== null) {
$dir = Plugin::path($plugin) . 'config' . DS . $folder;
$dir = CorePlugin::path($plugin) . 'config' . DS . $folder;
}

return $dir;
Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase/ConfigurationTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
namespace Migrations\Test;

use Cake\Core\BasePlugin;
use Cake\Core\Plugin;
use Cake\Datasource\ConnectionManager;
use Cake\TestSuite\TestCase;
Expand Down Expand Up @@ -140,7 +141,10 @@ public function testCacheMetadataDisabled()
public function testGetConfigWithPlugin()
{
$tmpPath = rtrim(sys_get_temp_dir(), DS) . DS;
Plugin::load('MyPlugin', ['path' => $tmpPath]);
Plugin::getCollection()->add(new BasePlugin([
'name' => 'MyPlugin',
'path' => $tmpPath,
]));
$input = $this->getMockBuilder('\Symfony\Component\Console\Input\InputInterface')->getMock();
$this->command->setInput($input);

Expand Down
16 changes: 8 additions & 8 deletions tests/TestCase/Shell/Task/MigrationSnapshotTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class MigrationSnapshotTaskTest extends TestCase
use StringCompareTrait;

public $fixtures = [
'plugin.migrations.users',
'plugin.migrations.special_tags',
'plugin.migrations.special_pk',
'plugin.migrations.composite_pk',
'plugin.migrations.products',
'plugin.migrations.categories',
'plugin.migrations.orders',
'plugin.migrations.articles'
'plugin.Migrations.Users',
'plugin.Migrations.SpecialTags',
'plugin.Migrations.SpecialPk',
'plugin.Migrations.CompositePk',
'plugin.Migrations.Products',
'plugin.Migrations.Categories',
'plugin.Migrations.Orders',
'plugin.Migrations.Articles'
];

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/TestCase/Shell/Task/SeedTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class SeedTaskTest extends TestCase
{
use StringCompareTrait;

public $fixtures = ['plugin.migrations.events', 'plugin.migrations.texts'];
public $fixtures = [
'plugin.Migrations.Events',
'plugin.Migrations.Texts'
];

/**
* ConsoleIo mock
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Helper/MigrationHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
class MigrationHelperTest extends TestCase
{
public $fixtures = [
'plugin.migrations.users',
'plugin.migrations.special_tags',
'plugin.Migrations.Users',
'plugin.Migrations.SpecialTags'
];

/**
Expand Down
14 changes: 8 additions & 6 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Datasource\ConnectionManager;
use Cake\Routing\Router;

$findRoot = function ($root) {
do {
Expand Down Expand Up @@ -43,6 +44,7 @@
Configure::write('debug', true);
Configure::write('App', [
'namespace' => 'TestApp',
'encoding' => 'UTF-8',
'paths' => [
'plugins' => [ROOT . 'Plugin' . DS],
'templates' => [ROOT . 'App' . DS . 'Template' . DS]
Expand All @@ -64,6 +66,9 @@
]
]);

// Store initial state
Router::reload();

if (!getenv('db_dsn')) {
putenv('db_dsn=sqlite://127.0.0.1/cakephp_test');
}
Expand All @@ -76,12 +81,9 @@
ConnectionManager::setConfig('test_comparisons', ['url' => getenv('db_dsn_compare')]);
}

Plugin::load('Migrations', [
'path' => dirname(dirname(__FILE__)) . DS,
]);
Plugin::load('TestBlog', [
'path' => ROOT . 'Plugin' . DS . 'TestBlog' . DS,
]);
Plugin::getCollection()->add(new \Migrations\Plugin());
Plugin::getCollection()->add(new \TestBlog\Plugin());

if (!defined('PHINX_VERSION')) {
define('PHINX_VERSION', (0 === strpos('@PHINX_VERSION@', '@PHINX_VERSION')) ? '0.4.3' : '@PHINX_VERSION@');
}
14 changes: 14 additions & 0 deletions tests/test_app/Plugin/TestBlog/src/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace TestBlog;

use Cake\Core\BasePlugin;

class Plugin extends BasePlugin
{
/**
* Plugin name.
*
* @var string
*/
protected $name = 'TestBlog';
}

0 comments on commit b514818

Please sign in to comment.