Browse Source

Merge branch 'master' into 3.next

Mark Story 7 years ago
parent
commit
0c7c731a15

+ 1 - 1
appveyor.yml

@@ -46,7 +46,7 @@ install:
   - echo extension=php_wincache.dll >> php.ini
   - echo wincache.enablecli = 1 >> php.ini
   - cd C:\projects\cakephp
-  - appveyor DownloadFile https://getcomposer.org/composer.phar
+  - curl -fsS https://getcomposer.org/composer.phar -o composer.phar
   - php composer.phar install --prefer-dist --no-interaction --ansi --no-progress
   - php -i | grep "ICU version"
 

+ 1 - 0
src/Core/ObjectRegistry.php

@@ -70,6 +70,7 @@ abstract class ObjectRegistry implements Countable, IteratorAggregate
      * @param string $objectName The name/class of the object to load.
      * @param array $config Additional settings to use when loading the object.
      * @return mixed
+     * @throws \Exception If the class cannot be found.
      */
     public function load($objectName, $config = [])
     {

+ 8 - 3
src/Core/Plugin.php

@@ -155,9 +155,14 @@ class Plugin
         if (!isset($config['configPath'])) {
             $config['configPath'] = $config['path'] . 'config' . DIRECTORY_SEPARATOR;
         }
-
-        // Use stub plugins as this method will be removed long term.
-        static::getCollection()->add(new BasePlugin($config));
+        $pluginClass = str_replace('/', '\\', $plugin) . '\\Plugin';
+        if (class_exists($pluginClass)) {
+            $instance = new $pluginClass($config);
+        } else {
+            // Use stub plugin as this method will be removed long term.
+            $instance = new BasePlugin($config);
+        }
+        static::getCollection()->add($instance);
 
         if ($config['autoload'] === true) {
             if (empty(static::$_loader)) {

+ 1 - 13
src/Database/Statement/BufferedStatement.php

@@ -42,7 +42,7 @@ class BufferedStatement extends StatementDecorator
      *
      * @var bool
      */
-    protected $_allFetched = true;
+    protected $_allFetched = false;
 
     /**
      * Current record pointer
@@ -52,18 +52,6 @@ class BufferedStatement extends StatementDecorator
     protected $_counter = 0;
 
     /**
-     * Constructor
-     *
-     * @param \Cake\Database\StatementInterface|null $statement Statement implementation such as PDOStatement
-     * @param \Cake\Database\Driver|null $driver Driver instance
-     */
-    public function __construct($statement = null, $driver = null)
-    {
-        parent::__construct($statement, $driver);
-        $this->_reset();
-    }
-
-    /**
      * Execute the statement and return the results.
      *
      * @param array|null $params list of values to be bound to query

+ 2 - 1
src/Http/Response.php

@@ -338,7 +338,8 @@ class Response implements ResponseInterface
         'vtt' => 'text/vtt',
         'mkv' => 'video/x-matroska',
         'pkpass' => 'application/vnd.apple.pkpass',
-        'ajax' => 'text/html'
+        'ajax' => 'text/html',
+        'bmp' => 'image/bmp'
     ];
 
     /**

+ 1 - 1
src/ORM/LazyEagerLoader.php

@@ -36,7 +36,7 @@ class LazyEagerLoader
      *
      * @param \Cake\Datasource\EntityInterface|array $entities a single entity or list of entities
      * @param array $contain A `contain()` compatible array.
-     * @see \Cake\ORM\Query\contain()
+     * @see \Cake\ORM\Query::contain()
      * @param \Cake\ORM\Table $source The table to use for fetching the top level entities
      * @return \Cake\Datasource\EntityInterface|array
      */

+ 2 - 2
src/ORM/Table.php

@@ -960,13 +960,13 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
     /**
      * Returns an association object configured for the specified alias if any.
      *
-     * @deprecated 3.6.0 Use getAssociation() and Table::hasAssocation() instead.
+     * @deprecated 3.6.0 Use getAssociation() and Table::hasAssociation() instead.
      * @param string $name the alias used for the association.
      * @return \Cake\ORM\Association|null Either the association or null.
      */
     public function association($name)
     {
-        deprecationWarning('Use Table::getAssociation() and Table::hasAssocation() instead.');
+        deprecationWarning('Use Table::getAssociation() and Table::hasAssociation() instead.');
 
         return $this->findAssociation($name);
     }

+ 39 - 4
tests/TestCase/Core/PluginTest.php

@@ -13,15 +13,27 @@
  */
 namespace Cake\Test\TestCase\Core;
 
+use Cake\Core\BasePlugin;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
 use Cake\TestSuite\TestCase;
+use TestPlugin\Plugin as TestPlugin;
 
 /**
  * PluginTest class
  */
 class PluginTest extends TestCase
 {
+    /**
+     * Setup
+     *
+     * @return void
+     */
+    public function setUp()
+    {
+        parent::setUp();
+        Plugin::unload();
+    }
 
     /**
      * Reverts the changes done to the environment while testing
@@ -41,13 +53,36 @@ class PluginTest extends TestCase
      */
     public function testLoad()
     {
-        Plugin::unload();
         Plugin::load('TestPlugin');
         $expected = ['TestPlugin'];
         $this->assertEquals($expected, Plugin::loaded());
     }
 
     /**
+     * Tests loading a plugin with a class
+     *
+     * @return void
+     */
+    public function testLoadConcreteClass()
+    {
+        Plugin::load('TestPlugin');
+        $instance = Plugin::getCollection()->get('TestPlugin');
+        $this->assertSame(TestPlugin::class, get_class($instance));
+    }
+
+    /**
+     * Tests loading a plugin without a class
+     *
+     * @return void
+     */
+    public function testLoadDynamicClass()
+    {
+        Plugin::load('TestPluginTwo');
+        $instance = Plugin::getCollection()->get('TestPluginTwo');
+        $this->assertSame(BasePlugin::class, get_class($instance));
+    }
+
+    /**
      * Tests unloading plugins
      *
      * @return void
@@ -217,9 +252,9 @@ class PluginTest extends TestCase
     public function testIgnoreMissingFiles()
     {
         Plugin::loadAll([[
-                'bootstrap' => true,
-                'routes' => true,
-                'ignoreMissing' => true
+            'bootstrap' => true,
+            'routes' => true,
+            'ignoreMissing' => true
         ]]);
         $this->assertTrue(Plugin::routes());
     }