Browse Source

Merge branch 'master' into 3.next

ADmad 7 years ago
parent
commit
bb655b1d8d
3 changed files with 36 additions and 8 deletions
  1. 2 2
      phpstan.neon
  2. 0 6
      src/Console/ConsoleIo.php
  3. 34 0
      tests/TestCase/Database/Schema/PostgresSchemaTest.php

+ 2 - 2
phpstan.neon

@@ -27,8 +27,8 @@ parameters:
         - '#Variable \$_SESSION in isset\(\) always exists and is not nullable#'
         - '#PHPDoc tag @throws with type PHPUnit\\Exception is not subtype of Throwable#'
         - '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject#'
-        - '#Method Redis::setex\(\) invoked with 3 parameters, 0 required#'
-        - '#Method Redis::setnx\(\) invoked with 2 parameters, 0 required#'
+        - '#Binary operation "\+" between array|false and array results in an error#'
+        - '#Result of method Cake\\Auth\\BaseAuthenticate::unauthenticated\(\) \(void\) is used#'
     earlyTerminatingMethodCalls:
         Cake\Console\Shell:
             - abort

+ 0 - 6
src/Console/ConsoleIo.php

@@ -540,12 +540,6 @@ class ConsoleIo
      */
     public function createFile($path, $contents, $forceOverwrite = false)
     {
-        $path = str_replace(
-            DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,
-            DIRECTORY_SEPARATOR,
-            $path
-        );
-
         $this->out();
         $forceOverwrite = $forceOverwrite || $this->forceOverwrite;
 

+ 34 - 0
tests/TestCase/Database/Schema/PostgresSchemaTest.php

@@ -638,6 +638,40 @@ SQL;
     }
 
     /**
+     * Test describing a table with postgres function defaults
+     *
+     * @return void
+     */
+    public function testDescribeTableFunctionDefaultValue()
+    {
+        $this->_needsConnection();
+        $connection = ConnectionManager::get('test');
+        $sql = <<<SQL
+CREATE TABLE schema_function_defaults (
+    "id" SERIAL,
+    year INT DEFAULT DATE_PART('year'::text, NOW()),
+    PRIMARY KEY("id")
+);
+SQL;
+        $connection->execute($sql);
+        $schema = new SchemaCollection($connection);
+        $result = $schema->describe('schema_function_defaults');
+        $connection->execute('DROP TABLE schema_function_defaults');
+
+        $expected = [
+            'type' => 'integer',
+            'default' => "date_part('year'::text, now())",
+            'null' => true,
+            'precision' => null,
+            'length' => 10,
+            'comment' => null,
+            'unsigned' => null,
+            'autoIncrement' => null,
+        ];
+        $this->assertEquals($expected, $result->getColumn('year'));
+    }
+
+    /**
      * Column provider for creating column sql
      *
      * @return array