diff --git a/.gitignore b/.gitignore index 3b2d2d2c..b3bc0771 100644 --- a/.gitignore +++ b/.gitignore @@ -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 # ################################# diff --git a/src/ConfigurationTrait.php b/src/ConfigurationTrait.php index aa1e4083..5a333806 100644 --- a/src/ConfigurationTrait.php +++ b/src/ConfigurationTrait.php @@ -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; @@ -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, diff --git a/src/Plugin.php b/src/Plugin.php new file mode 100644 index 00000000..42529a3f --- /dev/null +++ b/src/Plugin.php @@ -0,0 +1,34 @@ +has($pluginName)) { return []; } $list = []; @@ -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; } diff --git a/src/Util/UtilTrait.php b/src/Util/UtilTrait.php index aec2309d..5afaf8db 100644 --- a/src/Util/UtilTrait.php +++ b/src/Util/UtilTrait.php @@ -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; @@ -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; diff --git a/tests/TestCase/ConfigurationTraitTest.php b/tests/TestCase/ConfigurationTraitTest.php index dd4c36e9..825e64ed 100644 --- a/tests/TestCase/ConfigurationTraitTest.php +++ b/tests/TestCase/ConfigurationTraitTest.php @@ -11,6 +11,7 @@ */ namespace Migrations\Test; +use Cake\Core\BasePlugin; use Cake\Core\Plugin; use Cake\Datasource\ConnectionManager; use Cake\TestSuite\TestCase; @@ -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); diff --git a/tests/TestCase/Shell/Task/MigrationSnapshotTaskTest.php b/tests/TestCase/Shell/Task/MigrationSnapshotTaskTest.php index e7550c94..733802a6 100644 --- a/tests/TestCase/Shell/Task/MigrationSnapshotTaskTest.php +++ b/tests/TestCase/Shell/Task/MigrationSnapshotTaskTest.php @@ -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' ]; /** diff --git a/tests/TestCase/Shell/Task/SeedTaskTest.php b/tests/TestCase/Shell/Task/SeedTaskTest.php index 0362121d..8e434798 100644 --- a/tests/TestCase/Shell/Task/SeedTaskTest.php +++ b/tests/TestCase/Shell/Task/SeedTaskTest.php @@ -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 diff --git a/tests/TestCase/View/Helper/MigrationHelperTest.php b/tests/TestCase/View/Helper/MigrationHelperTest.php index 4f57d9af..99c02f4e 100644 --- a/tests/TestCase/View/Helper/MigrationHelperTest.php +++ b/tests/TestCase/View/Helper/MigrationHelperTest.php @@ -25,8 +25,8 @@ class MigrationHelperTest extends TestCase { public $fixtures = [ - 'plugin.migrations.users', - 'plugin.migrations.special_tags', + 'plugin.Migrations.Users', + 'plugin.Migrations.SpecialTags' ]; /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ed2f18c8..47591283 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,6 +13,7 @@ use Cake\Core\Configure; use Cake\Core\Plugin; use Cake\Datasource\ConnectionManager; +use Cake\Routing\Router; $findRoot = function ($root) { do { @@ -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] @@ -64,6 +66,9 @@ ] ]); +// Store initial state +Router::reload(); + if (!getenv('db_dsn')) { putenv('db_dsn=sqlite://127.0.0.1/cakephp_test'); } @@ -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@'); } diff --git a/tests/test_app/Plugin/TestBlog/src/Plugin.php b/tests/test_app/Plugin/TestBlog/src/Plugin.php new file mode 100644 index 00000000..155f233d --- /dev/null +++ b/tests/test_app/Plugin/TestBlog/src/Plugin.php @@ -0,0 +1,14 @@ +