|
|
@@ -21,6 +21,7 @@ use Cake\Database\Exception\MissingConnectionException;
|
|
|
use Cake\Database\Exception\NestedTransactionRollbackException;
|
|
|
use Cake\Database\Log\LoggingStatement;
|
|
|
use Cake\Database\Log\QueryLogger;
|
|
|
+use Cake\Database\Schema\CachedCollection;
|
|
|
use Cake\Database\StatementInterface;
|
|
|
use Cake\Database\Statement\BufferedStatement;
|
|
|
use Cake\Datasource\ConnectionManager;
|
|
|
@@ -1168,6 +1169,43 @@ class ConnectionTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test CachedCollection creation with default and custom cache key prefix.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetCachedCollection()
|
|
|
+ {
|
|
|
+ $driver = $this->getMockFormDriver();
|
|
|
+ $connection = $this->getMockBuilder(Connection::class)
|
|
|
+ ->setMethods(['connect'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
+ 'driver' => $driver,
|
|
|
+ 'name' => 'default',
|
|
|
+ 'cacheMetadata' => true,
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
+
|
|
|
+ $schema = $connection->getSchemaCollection();
|
|
|
+ $this->assertInstanceOf(CachedCollection::class, $schema);
|
|
|
+ $this->assertSame('default_key', $schema->cacheKey('key'));
|
|
|
+
|
|
|
+ $driver = $this->getMockFormDriver();
|
|
|
+ $connection = $this->getMockBuilder(Connection::class)
|
|
|
+ ->setMethods(['connect'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
+ 'driver' => $driver,
|
|
|
+ 'name' => 'default',
|
|
|
+ 'cacheMetadata' => true,
|
|
|
+ 'cacheKeyPrefix' => 'foo',
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
+
|
|
|
+ $schema = $connection->getSchemaCollection();
|
|
|
+ $this->assertInstanceOf(CachedCollection::class, $schema);
|
|
|
+ $this->assertSame('foo_key', $schema->cacheKey('key'));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Tests that allowed nesting of commit/rollback operations doesn't
|
|
|
* throw any exceptions.
|
|
|
*
|