Browse Source

Merge branch 'master' of github.com:cakephp/cakephp

Mark Story 7 years ago
parent
commit
c0d6f8f50a
2 changed files with 24 additions and 0 deletions
  1. 2 0
      src/Core/PluginCollection.php
  2. 22 0
      tests/TestCase/Core/PluginCollectionTest.php

+ 2 - 0
src/Core/PluginCollection.php

@@ -109,6 +109,8 @@ class PluginCollection implements Iterator, Countable
      */
     public function findPath($name)
     {
+        $this->loadConfig();
+
         $path = Configure::read('plugins.' . $name);
         if ($path) {
             return $path;

+ 22 - 0
tests/TestCase/Core/PluginCollectionTest.php

@@ -148,6 +148,28 @@ class PluginCollectionTest extends TestCase
         $this->assertEquals(TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS, $path);
     }
 
+    public function testFindPathLoadsConfigureData()
+    {
+        $configPath = ROOT . DS . 'cakephp-plugins.php';
+        $this->skipIf(file_exists($configPath), 'cakephp-plugins.php exists, skipping overwrite');
+        $file = <<<PHP
+<?php
+return [
+    'plugins' => [
+        'TestPlugin' => '/config/path'
+    ]
+];
+PHP;
+        file_put_contents($configPath, $file);
+
+        Configure::delete('plugins');
+        $plugins = new PluginCollection();
+        $path = $plugins->findPath('TestPlugin');
+        unlink($configPath);
+
+        $this->assertEquals('/config/path', $path);
+    }
+
     public function testFindPathConfigureData()
     {
         Configure::write('plugins', ['TestPlugin' => '/some/path']);