Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 44 additions & 23 deletions Tests/AbstractDatabaseDriverTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function testGetNumRows()
$this->loadExampleData();

static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
->where(static::$connection->quoteName('description') . ' = ' . static::$connection->quote('test row one'))
Expand All @@ -209,7 +209,7 @@ public function testGetNumRows()
*/
public function testGetQueryCachedQuery()
{
$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->select('*')
->from('#__dbtest');

Expand All @@ -226,7 +226,7 @@ public function testGetIterator()
$this->loadExampleData();

static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
);
Expand Down Expand Up @@ -327,6 +327,27 @@ public function testIsMinimumVersion()
);
}

/**
* @testdox The first row of a result set can be loaded as an associative array, using old getQuery(true) syntax
*/
public function testLoadAssocWithOldGetQueryTrueSyntax()
{
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
->select('title')
->from('#__dbtest')
)->loadAssoc();

$this->assertEquals(
[
'title' => 'Testing1',
],
$result
);
}

/**
* @testdox The first row of a result set can be loaded as an associative array
*/
Expand All @@ -335,7 +356,7 @@ public function testLoadAssoc()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('title')
->from('#__dbtest')
)->loadAssoc();
Expand All @@ -356,7 +377,7 @@ public function testLoadAssocList()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('title')
->from('#__dbtest')
)->loadAssocList();
Expand All @@ -380,7 +401,7 @@ public function testLoadColumn()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('title')
->from('#__dbtest')
)->loadColumn();
Expand All @@ -404,7 +425,7 @@ public function testLoadObject()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
)->loadObject();
Expand All @@ -428,7 +449,7 @@ public function testLoadObjectList()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
)->loadObjectList();
Expand Down Expand Up @@ -475,7 +496,7 @@ public function testLoadResult()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
)->loadResult();
Expand All @@ -491,7 +512,7 @@ public function testLoadRow()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
)->loadRow();
Expand All @@ -515,7 +536,7 @@ public function testLoadRowList()
$this->loadExampleData();

$result = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
)->loadRowList();
Expand Down Expand Up @@ -668,7 +689,7 @@ public function testGetAndSetQueryMonitor()
*/
public function testSetQueryWithQueryObjectWithoutOffsetOrLimit()
{
$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->select('*')
->from('#__dbtest');

Expand All @@ -690,7 +711,7 @@ public function testSetQueryWithQueryObjectWithoutOffsetOrLimit()
*/
public function testSetQueryWithQueryObjectWithOffsetAndLimit()
{
$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->select('*')
->from('#__dbtest');

Expand Down Expand Up @@ -726,7 +747,7 @@ public function testSetQueryWithQueryObjectWithOffsetAndLimit()
*/
public function testSetQueryWithQueryObjectWithOffsetAndLimitOnQuery()
{
$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->select('*')
->from('#__dbtest')
->setLimit(10, 3);
Expand Down Expand Up @@ -821,7 +842,7 @@ public function testUpdateObject()

// Fetch row to validate update
$row = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
->where('id = :id')
Expand All @@ -838,9 +859,9 @@ public function testQuerySetWithUnionAll()
{
$this->loadExampleData();

$query = static::$connection->getQuery(true);
$union1 = static::$connection->getQuery(true);
$union2 = static::$connection->getQuery(true);
$query = static::$connection->createQuery();
$union1 = static::$connection->createQuery();
$union2 = static::$connection->createQuery();

$union1->select('id, title')
->from('#__dbtest')
Expand Down Expand Up @@ -876,8 +897,8 @@ public function testSelectToQuerySetWithUnionAll()
{
$this->loadExampleData();

$query = static::$connection->getQuery(true);
$union = static::$connection->getQuery(true);
$query = static::$connection->createQuery();
$union = static::$connection->createQuery();

$query->select('id, title')
->from('#__dbtest')
Expand Down Expand Up @@ -912,7 +933,7 @@ public function testRepeatedSelectStatement()
$this->loadExampleData();
$results = [];

$query = static::$connection->getQuery(true);
$query = static::$connection->createQuery();
$query->select('id, title')
->from('#__dbtest')
->where('id = :id')
Expand Down Expand Up @@ -948,7 +969,7 @@ public function testMonitorWithReusableQuery()
static::$connection->setMonitor(new DebugMonitor);

$title = 'test';
$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->select('id')
->from('#__dbtest')
->where('title = :title')
Expand Down Expand Up @@ -991,7 +1012,7 @@ public function testMonitorWithRepeatedStatement()
{
static::$connection->setMonitor(new DebugMonitor);

$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->select('id')
->from('#__dbtest')
->where('id = :id')
Expand Down
22 changes: 11 additions & 11 deletions Tests/Mysql/MysqlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public function testTransactionCommit()

// Insert row
static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->insert('#__dbtest')
->columns(['id', 'title', 'start_date', 'description'])
->values(':id, :title, :start_date, :description')
Expand All @@ -376,7 +376,7 @@ public function testTransactionCommit()
$this->assertSame(1, static::$connection->getAffectedRows());

$row = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
->where('id = :id')
Expand Down Expand Up @@ -419,7 +419,7 @@ public function testTransactionRollback(?string $toSavepoint, int $tupleCount)
$description = 'testRollbackSp';

static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->insert('#__dbtest')
->columns(['id', 'title', 'start_date', 'description'])
->values(':id, :title, :start_date, :description')
Expand All @@ -440,7 +440,7 @@ public function testTransactionRollback(?string $toSavepoint, int $tupleCount)
$startDate = '2019-10-27';

static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->insert('#__dbtest')
->columns(['id', 'title', 'start_date', 'description'])
->values(':id, :title, :start_date, :description')
Expand All @@ -465,7 +465,7 @@ public function testTransactionRollback(?string $toSavepoint, int $tupleCount)
* - 1 if a savepoint exists
*/
$transactionRows = static::$connection->setQuery(
static::$connection->getQuery(true)
static::$connection->createQuery()
->select('*')
->from('#__dbtest')
->where('description = :description')
Expand Down Expand Up @@ -556,7 +556,7 @@ public function testGetQueryNewInstance()
{
$this->assertInstanceOf(
MysqlQuery::class,
static::$connection->getQuery(true)
static::$connection->createQuery()
);
}

Expand All @@ -568,27 +568,27 @@ public function testQuoteAndDecodeBinary()
$this->loadExampleData();

// Add binary data with null byte
$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->update('#__dbtest')
->set('data = ' . static::$connection->quoteBinary("\x00\x01\x02\xff"))
->where('id = 3');

static::$connection->setQuery($query)->execute();

// Add binary data with invalid UTF-8
$query = static::$connection->getQuery(true)
$query = static::$connection->createQuery()
->update('#__dbtest')
->set('data = ' . static::$connection->quoteBinary("\x01\x01\x02\xff"))
->where('id = 4');

static::$connection->setQuery($query)->execute();

$selectRow3 = static::$connection->getQuery(true)
$selectRow3 = static::$connection->createQuery()
->select('id')
->from('#__dbtest')
->where('data = ' . static::$connection->quoteBinary("\x00\x01\x02\xff"));

$selectRow4 = static::$connection->getQuery(true)
$selectRow4 = static::$connection->createQuery()
->select('id')
->from('#__dbtest')
->where('data = ' . static::$connection->quoteBinary("\x01\x01\x02\xff"));
Expand All @@ -599,7 +599,7 @@ public function testQuoteAndDecodeBinary()
$result = static::$connection->setQuery($selectRow4)->loadResult();
$this->assertEquals(4, $result);

$selectRows = static::$connection->getQuery(true)
$selectRows = static::$connection->createQuery()
->select('data')
->from('#__dbtest')
->order('id');
Expand Down
Loading