add tests for queryWalk()

This commit is contained in:
Sergey Tsalkov
2021-06-25 17:35:39 +00:00
parent 15f40efe5d
commit cd64dd724b
2 changed files with 26 additions and 0 deletions

24
simpletest/WalkTest.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
class WalkTest extends SimpleTest {
function test_1_walk() {
$Walk = DB::queryWalk("SELECT * FROM accounts");
$results = array();
while ($row = $Walk->next()) {
$results[] = $row;
}
$this->assert(count($results) == 8);
$this->assert($results[7]['username'] == 'vookoo');
}
function test_2_walk_stop() {
$Walk = DB::queryWalk("SELECT * FROM accounts");
$Walk->next();
unset($Walk);
// if $Walk hasn't been properly freed, this will produce an out of sync error
DB::query("SELECT * FROM accounts");
}
}