Browse Source

Merge branch 'master' into 3.next

Mark Story 7 years ago
parent
commit
24c03dcba7

+ 1 - 1
src/Http/ServerRequest.php

@@ -315,7 +315,7 @@ class ServerRequest implements ArrayAccess, ServerRequestInterface
      */
      */
     protected function _setConfig($config)
     protected function _setConfig($config)
     {
     {
-        if (!empty($config['url']) && $config['url'][0] === '/') {
+        if (strlen($config['url']) > 1 && $config['url'][0] === '/') {
             $config['url'] = substr($config['url'], 1);
             $config['url'] = substr($config['url'], 1);
         }
         }
 
 

+ 1 - 1
src/ORM/Table.php

@@ -773,7 +773,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
                 return $this->_entityClass = $default;
                 return $this->_entityClass = $default;
             }
             }
 
 
-            $alias = Inflector::classify(Inflector::singularize(Inflector::underscore(substr(array_pop($parts), 0, -5))));
+            $alias = Inflector::classify(Inflector::underscore(substr(array_pop($parts), 0, -5)));
             $name = implode('\\', array_slice($parts, 0, -1)) . '\\Entity\\' . $alias;
             $name = implode('\\', array_slice($parts, 0, -1)) . '\\Entity\\' . $alias;
             if (!class_exists($name)) {
             if (!class_exists($name)) {
                 return $this->_entityClass = $default;
                 return $this->_entityClass = $default;

+ 1 - 1
src/TestSuite/TestCase.php

@@ -730,7 +730,7 @@ abstract class TestCase extends BaseTestCase
 
 
         if (empty($options['entityClass']) && $mock->getEntityClass() === Entity::class) {
         if (empty($options['entityClass']) && $mock->getEntityClass() === Entity::class) {
             $parts = explode('\\', $className);
             $parts = explode('\\', $className);
-            $entityAlias = Inflector::singularize(substr(array_pop($parts), 0, -5));
+            $entityAlias = Inflector::classify(Inflector::underscore(substr(array_pop($parts), 0, -5)));
             $entityClass = implode('\\', array_slice($parts, 0, -1)) . '\\Entity\\' . $entityAlias;
             $entityClass = implode('\\', array_slice($parts, 0, -1)) . '\\Entity\\' . $entityAlias;
             if (class_exists($entityClass)) {
             if (class_exists($entityClass)) {
                 $mock->setEntityClass($entityClass);
                 $mock->setEntityClass($entityClass);

+ 16 - 0
tests/TestCase/Http/ServerRequestTest.php

@@ -159,6 +159,22 @@ class ServerRequestTest extends TestCase
     }
     }
 
 
     /**
     /**
+     * Test constructing with a string url.
+     *
+     * @deprecated
+     * @return void
+     */
+    public function testConstructStringUrlIgnoreServer()
+    {
+        $_SERVER['REQUEST_URI'] = '/some/other/path';
+
+        $request = new ServerRequest('/articles/view/1');
+        $this->assertEquals('/articles/view/1', $request->getUri()->getPath());
+
+        $request = new ServerRequest('/');
+        $this->assertEquals('/', $request->getUri()->getPath());
+    }
+    /**
      * Test that querystring args provided in the URL string are parsed.
      * Test that querystring args provided in the URL string are parsed.
      *
      *
      * @return void
      * @return void

+ 7 - 0
tests/TestCase/ORM/TableTest.php

@@ -1520,6 +1520,13 @@ class TableTest extends TestCase
 
 
         $table = $this->getTableLocator()->get('CustomCookies');
         $table = $this->getTableLocator()->get('CustomCookies');
         $this->assertEquals('TestApp\Model\Entity\CustomCookie', $table->getEntityClass());
         $this->assertEquals('TestApp\Model\Entity\CustomCookie', $table->getEntityClass());
+
+        if (!class_exists('TestApp\Model\Entity\Address')) {
+            class_alias($class, 'TestApp\Model\Entity\Address');
+        }
+
+        $table = $this->getTableLocator()->get('Addresses');
+        $this->assertEquals('TestApp\Model\Entity\Address', $table->getEntityClass());
     }
     }
 
 
     /**
     /**

+ 22 - 0
tests/test_app/TestApp/Model/Table/AddressesTable.php

@@ -0,0 +1,22 @@
+<?php
+/**
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice
+ *
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
+ * @since         3.6.9
+ * @license       https://opensource.org/licenses/mit-license.php MIT License
+ */
+namespace TestApp\Model\Table;
+
+use Cake\ORM\Table;
+
+/**
+ * Addresses table class
+ */
+class AddressesTable extends Table
+{
+}