Browse Source

Remove deprecated methods from Connection.

ADmad 8 years ago
parent
commit
d9206d432b

+ 0 - 92
src/Database/Connection.php

@@ -206,29 +206,6 @@ class Connection implements ConnectionInterface
     }
 
     /**
-     * Sets the driver instance. If a string is passed it will be treated
-     * as a class name and will be instantiated.
-     *
-     * If no params are passed it will return the current driver instance.
-     *
-     * @deprecated 3.4.0 Use setDriver()/getDriver() instead.
-     * @param \Cake\Database\Driver|string|null $driver The driver instance to use.
-     * @param array $config Either config for a new driver or null.
-     * @throws \Cake\Database\Exception\MissingDriverException When a driver class is missing.
-     * @throws \Cake\Database\Exception\MissingExtensionException When a driver's PHP extension is missing.
-     * @return \Cake\Database\Driver
-     */
-    public function driver($driver = null, $config = [])
-    {
-        deprecationWarning('Connection::driver() is deprecated. Use Connection::setDriver()/getDriver() instead.');
-        if ($driver !== null) {
-            $this->setDriver($driver, $config);
-        }
-
-        return $this->getDriver();
-    }
-
-    /**
      * Connects to the configured database.
      *
      * @throws \Cake\Database\Exception\MissingConnectionException if credentials are invalid.
@@ -395,26 +372,6 @@ class Connection implements ConnectionInterface
     }
 
     /**
-     * Gets or sets a Schema\Collection object for this connection.
-     *
-     * @deprecated 3.4.0 Use setSchemaCollection()/getSchemaCollection()
-     * @param \Cake\Database\Schema\Collection|null $collection The schema collection object
-     * @return \Cake\Database\Schema\Collection
-     */
-    public function schemaCollection(SchemaCollection $collection = null)
-    {
-        deprecationWarning(
-            'Connection::schemaCollection() is deprecated. ' .
-            'Use Connection::setSchemaCollection()/getSchemaCollection() instead.'
-        );
-        if ($collection !== null) {
-            $this->setSchemaCollection($collection);
-        }
-
-        return $this->getSchemaCollection();
-    }
-
-    /**
      * Executes an INSERT query on the specified table.
      *
      * @param string $table the table to insert values in
@@ -609,37 +566,6 @@ class Connection implements ConnectionInterface
     }
 
     /**
-     * Returns whether this connection is using savepoints for nested transactions
-     * If a boolean is passed as argument it will enable/disable the usage of savepoints
-     * only if driver the allows it.
-     *
-     * If you are trying to enable this feature, make sure you check the return value of this
-     * function to verify it was enabled successfully.
-     *
-     * ### Example:
-     *
-     * `$connection->useSavePoints(true)` Returns true if drivers supports save points, false otherwise
-     * `$connection->useSavePoints(false)` Disables usage of savepoints and returns false
-     * `$connection->useSavePoints()` Returns current status
-     *
-     * @deprecated 3.4.0 Use enableSavePoints()/isSavePointsEnabled() instead.
-     * @param bool|null $enable Whether or not save points should be used.
-     * @return bool true if enabled, false otherwise
-     */
-    public function useSavePoints($enable = null)
-    {
-        deprecationWarning(
-            'Connection::useSavePoints() is deprecated. ' .
-            'Use Connection::enableSavePoints()/isSavePointsEnabled() instead.'
-        );
-        if ($enable !== null) {
-            $this->enableSavePoints($enable);
-        }
-
-        return $this->isSavePointsEnabled();
-    }
-
-    /**
      * Creates a new save point for nested transactions.
      *
      * @param string $name The save point name.
@@ -857,24 +783,6 @@ class Connection implements ConnectionInterface
     }
 
     /**
-     * {@inheritDoc}
-     *
-     * @deprecated 3.5.0 Use getLogger() and setLogger() instead.
-     */
-    public function logger($instance = null)
-    {
-        deprecationWarning(
-            'Connection::logger() is deprecated. ' .
-            'Use Connection::setLogger()/getLogger() instead.'
-        );
-        if ($instance === null) {
-            return $this->getLogger();
-        }
-
-        $this->setLogger($instance);
-    }
-
-    /**
      * Sets a logger
      *
      * @param \Cake\Database\Log\QueryLogger $logger Logger object

+ 0 - 4
src/Database/SchemaCache.php

@@ -98,10 +98,6 @@ class SchemaCache
      */
     public function getSchema(Connection $connection)
     {
-        if (!method_exists($connection, 'schemaCollection')) {
-            throw new RuntimeException('The given connection object is not compatible with schema caching, as it does not implement a "schemaCollection()" method.');
-        }
-
         $config = $connection->config();
         if (empty($config['cacheMetadata'])) {
             $connection->cacheMetadata(true);

+ 0 - 10
src/Datasource/ConnectionInterface.php

@@ -79,14 +79,4 @@ interface ConnectionInterface
      * @return bool
      */
     public function logQueries($enable = null);
-
-    /**
-     * Sets the logger object instance. When called with no arguments
-     * it returns the currently setup logger instance.
-     *
-     * @param object|null $instance logger object instance
-     * @return object logger instance
-     * @deprecated 3.5.0 Will be replaced by getLogger()/setLogger()
-     */
-    public function logger($instance = null);
 }

+ 0 - 41
tests/TestCase/Database/ConnectionTest.php

@@ -842,21 +842,6 @@ class ConnectionTest extends TestCase
     }
 
     /**
-     * Tests that a custom logger object can be set
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testSetLogger()
-    {
-        $this->deprecated(function () {
-            $logger = new QueryLogger;
-            $this->connection->logger($logger);
-            $this->assertSame($logger, $this->connection->logger());
-        });
-    }
-
-    /**
      * Tests setting and getting the logger object
      *
      * @return void
@@ -1074,32 +1059,6 @@ class ConnectionTest extends TestCase
     }
 
     /**
-     * Tests it is possible to set a schema collection object
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testSchemaCollection()
-    {
-        $this->deprecated(function () {
-            $driver = $this->getMockFormDriver();
-            $connection = $this->getMockBuilder(Connection::class)
-                ->setMethods(['connect'])
-                ->setConstructorArgs([['driver' => $driver]])
-                ->getMock();
-
-            $schema = $connection->schemaCollection();
-            $this->assertInstanceOf('Cake\Database\Schema\Collection', $schema);
-
-            $schema = $this->getMockBuilder('Cake\Database\Schema\Collection')
-                ->setConstructorArgs([$connection])
-                ->getMock();
-            $connection->schemaCollection($schema);
-            $this->assertSame($schema, $connection->schemaCollection());
-        });
-    }
-
-    /**
      * Tests that allowed nesting of commit/rollback operations doesn't
      * throw any exceptions.
      *