mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-02 14:18:46 +02:00
Update MySQLDatabaseTest to work with new query iterators
This commit is contained in:
parent
6ef5785fc5
commit
749405170c
@ -45,58 +45,50 @@ class MySQLDatabaseTest extends SapphireTest
|
|||||||
$this->assertInstanceOf(MySQLQuery::class, $result3);
|
$this->assertInstanceOf(MySQLQuery::class, $result3);
|
||||||
|
|
||||||
// Iterating one level should not buffer, but return the right result
|
// Iterating one level should not buffer, but return the right result
|
||||||
|
$result1Array = [];
|
||||||
|
foreach($result1 as $record) {
|
||||||
|
$result1Array[] = $record;
|
||||||
|
}
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
'Sort' => 1,
|
[ 'Sort' => 1, 'Title' => 'First Item' ],
|
||||||
'Title' => 'First Item'
|
[ 'Sort' => 2, 'Title' => 'Second Item' ],
|
||||||
|
[ 'Sort' => 3, 'Title' => 'Third Item' ],
|
||||||
|
[ 'Sort' => 4, 'Title' => 'Last Item' ],
|
||||||
],
|
],
|
||||||
$result1->next()
|
$result1Array
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
[
|
|
||||||
'Sort' => 2,
|
|
||||||
'Title' => 'Second Item'
|
|
||||||
],
|
|
||||||
$result1->next()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Test first
|
|
||||||
$this->assertEquals(
|
|
||||||
[
|
|
||||||
'Sort' => 1,
|
|
||||||
'Title' => 'First Item'
|
|
||||||
],
|
|
||||||
$result1->first()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Test seek
|
|
||||||
$this->assertEquals(
|
|
||||||
[
|
|
||||||
'Sort' => 2,
|
|
||||||
'Title' => 'Second Item'
|
|
||||||
],
|
|
||||||
$result1->seek(1)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test count
|
// Test count
|
||||||
$this->assertEquals(4, $result1->numRecords());
|
$this->assertEquals(4, $result1->numRecords());
|
||||||
|
|
||||||
|
// Test count
|
||||||
|
$this->assertEquals(4, $result1->numRecords());
|
||||||
|
|
||||||
// Test second statement
|
// Test second statement
|
||||||
|
$result2Array = [];
|
||||||
|
foreach($result2 as $record) {
|
||||||
|
$result2Array[] = $record;
|
||||||
|
break;
|
||||||
|
}
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
'Sort' => 3,
|
[ 'Sort' => 3, 'Title' => 'Third Item' ],
|
||||||
'Title' => 'Third Item'
|
|
||||||
],
|
],
|
||||||
$result2->next()
|
$result2Array
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test non-prepared query
|
// Test non-prepared query
|
||||||
|
$result3Array = [];
|
||||||
|
foreach($result3 as $record) {
|
||||||
|
$result3Array[] = $record;
|
||||||
|
break;
|
||||||
|
}
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
'Sort' => 1,
|
[ 'Sort' => 1, 'Title' => 'First Item' ],
|
||||||
'Title' => 'First Item'
|
|
||||||
],
|
],
|
||||||
$result3->next()
|
$result3Array
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user