|
3 | 3 | namespace XBase\Tests\TableEditor; |
4 | 4 |
|
5 | 5 | use PHPUnit\Framework\TestCase; |
| 6 | +use XBase\Column\ColumnInterface; |
6 | 7 | use XBase\Enum\TableType; |
7 | 8 | use XBase\Memo\MemoObject; |
8 | 9 | use XBase\Record\VisualFoxproRecord; |
@@ -314,4 +315,46 @@ public function testIssue91(): void |
314 | 315 | } |
315 | 316 | self::assertEquals($data, $actual); |
316 | 317 | } |
| 318 | + |
| 319 | + public function testIssue115(): void |
| 320 | + { |
| 321 | + $filename = __DIR__.'/../Resources/foxpro/issue115.dbf'; |
| 322 | + $table = new TableEditor($filename); |
| 323 | + |
| 324 | + $record = $table->appendRecord(); |
| 325 | + $record->cod = 'a'; |
| 326 | + $record->denumire = 'b'; |
| 327 | + $record->cont_van = 'c'; |
| 328 | + $record->tel = 'd'; |
| 329 | + $record->bi_serie = 'e'; |
| 330 | + $record->bi_numar = 'f'; |
| 331 | + $record->bi_pol = 'g'; |
| 332 | + $record->masina = 'h'; |
| 333 | + $record->blocat = 1; |
| 334 | + |
| 335 | + $table |
| 336 | + ->writeRecord() |
| 337 | + ->save() |
| 338 | + ->close(); |
| 339 | + unset($record, $table); |
| 340 | + |
| 341 | + $table = new TableReader($filename); |
| 342 | + self::assertSame( |
| 343 | + $table->getRecordByteLength(), |
| 344 | + array_reduce($table->getColumns(), static function (int $carry, ColumnInterface $c) { |
| 345 | + return $carry + $c->getLength(); |
| 346 | + }, 1) |
| 347 | + ); |
| 348 | + |
| 349 | + $record = $table->pickRecord($table->getRecordCount() - 1); |
| 350 | + self::assertSame($record->cod, 'a'); |
| 351 | + self::assertSame($record->denumire, 'b'); |
| 352 | + self::assertSame($record->cont_van, 'c'); |
| 353 | + self::assertSame($record->tel, 'd'); |
| 354 | + self::assertSame($record->bi_serie, 'e'); |
| 355 | + self::assertSame($record->bi_numar, 'f'); |
| 356 | + self::assertSame($record->bi_pol, 'g'); |
| 357 | + self::assertSame($record->masina, 'h'); |
| 358 | + self::assertSame($record->blocat, 1); |
| 359 | + } |
317 | 360 | } |
0 commit comments