|
8 | 8 | use Atk4\Data\Model;
|
9 | 9 | use Atk4\Data\Schema\TestCase;
|
10 | 10 | use Doctrine\DBAL\Platforms\OraclePlatform;
|
| 11 | +use Doctrine\DBAL\Platforms\SqlitePlatform; |
11 | 12 |
|
12 | 13 | class TypecastingTest extends TestCase
|
13 | 14 | {
|
@@ -110,10 +111,16 @@ public function testType(): void
|
110 | 111 |
|
111 | 112 | $this->assertEquals($first, $duplicate);
|
112 | 113 |
|
113 |
| - $m->load(2)->set('float', 8.202343767574731)->save(); |
| 114 | + $m->load(2)->set('float', 8.20234376757474)->save(); |
114 | 115 | // pack is needed to compare float numbers exactly, see https://github.com/sebastianbergmann/phpunit/issues/4966
|
115 |
| - // remove bin2hex/pack once fixed in phpunit officially |
116 |
| - $this->assertSame(bin2hex(pack('e', 8.202343767574731)), bin2hex(pack('e', $m->load(2)->get('float')))); |
| 116 | + // remove bin2hex/pack once phpunit is fixed officially |
| 117 | + $this->assertSame(bin2hex(pack('e', 8.20234376757474)), bin2hex(pack('e', $m->load(2)->get('float')))); |
| 118 | + $m->load(2)->set('float', 8.202343767574732)->save(); |
| 119 | + // pdo_sqlite in truncating float when converted to string, see https://github.com/php/php-src/issues/8510 |
| 120 | + // fixed since PHP 8.1, but if converted in SQL to string explicitly, the result is still wrong |
| 121 | + if (!$this->getDatabasePlatform() instanceof SqlitePlatform || \PHP_VERSION_ID >= 81000) { |
| 122 | + $this->assertSame(bin2hex(pack('e', 8.202343767574732)), bin2hex(pack('e', $m->load(2)->get('float')))); |
| 123 | + } |
117 | 124 | }
|
118 | 125 |
|
119 | 126 | public function testEmptyValues(): void
|
|
0 commit comments