Update MySQLDatabaseTest to work with new query iterators

This commit is contained in:
Loz Calver 2017-06-28 12:22:45 +01:00 committed by Guy Sartorelli
parent 6ef5785fc5
commit 749405170c
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A

View File

@ -45,58 +45,50 @@ class MySQLDatabaseTest extends SapphireTest
$this->assertInstanceOf(MySQLQuery::class, $result3);
// Iterating one level should not buffer, but return the right result
$result1Array = [];
foreach($result1 as $record) {
$result1Array[] = $record;
}
$this->assertEquals(
[
'Sort' => 1,
'Title' => 'First Item'
[ 'Sort' => 1, 'Title' => 'First Item' ],
[ 'Sort' => 2, 'Title' => 'Second Item' ],
[ 'Sort' => 3, 'Title' => 'Third Item' ],
[ 'Sort' => 4, 'Title' => 'Last Item' ],
],
$result1->next()
);
$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)
$result1Array
);
// Test count
$this->assertEquals(4, $result1->numRecords());
// Test count
$this->assertEquals(4, $result1->numRecords());
// Test second statement
$result2Array = [];
foreach($result2 as $record) {
$result2Array[] = $record;
break;
}
$this->assertEquals(
[
'Sort' => 3,
'Title' => 'Third Item'
[ 'Sort' => 3, 'Title' => 'Third Item' ],
],
$result2->next()
$result2Array
);
// Test non-prepared query
$result3Array = [];
foreach($result3 as $record) {
$result3Array[] = $record;
break;
}
$this->assertEquals(
[
'Sort' => 1,
'Title' => 'First Item'
[ 'Sort' => 1, 'Title' => 'First Item' ],
],
$result3->next()
$result3Array
);
}