| @@ 81-92 (lines=12) @@ | ||
| 78 | ||
| 79 | } |
|
| 80 | ||
| 81 | public function testEach(){ |
|
| 82 | $this->DBResult->__each(function($row, $i){ |
|
| 83 | /** @var \chillerlan\Database\DBResultRow $row */ |
|
| 84 | $this->assertSame($row->id, $i); |
|
| 85 | $this->assertSame(md5($row->id), $row->hash()); |
|
| 86 | ||
| 87 | $row->__each(function($v, $j) use ($row){ |
|
| 88 | $this->assertSame($row->{$j}, $v); |
|
| 89 | $this->assertSame($row[$j], $v); |
|
| 90 | }); |
|
| 91 | }); |
|
| 92 | } |
|
| 93 | ||
| 94 | } |
|
| 95 | ||
| @@ 59-68 (lines=10) @@ | ||
| 56 | ||
| 57 | $this->assertCount(10, $DBResult); |
|
| 58 | ||
| 59 | $DBResult->__each(function($row, $i){ |
|
| 60 | /** @var \chillerlan\Database\DBResultRow $row */ |
|
| 61 | $this->assertEquals($row->{$this->SQL_INDEX_COL}, $i); |
|
| 62 | $this->assertSame(md5($row->{$this->SQL_INDEX_COL}), $row->{$this->SQL_DATA_COL}()); |
|
| 63 | ||
| 64 | $row->__each(function($v, $j) use ($row){ |
|
| 65 | $this->assertEquals($row->{$j}, $v); |
|
| 66 | $this->assertEquals($row[$j], $v); |
|
| 67 | }); |
|
| 68 | }); |
|
| 69 | ||
| 70 | $this->assertTrue($this->DBDriver->raw($this->SQL_RAW_TRUNCATE)); |
|
| 71 | } |
|