Skip to content

Commit 9b71464

Browse files
committed
refactor float type column tests
1 parent ad6b508 commit 9b71464

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed

tests/Functional/Schema/MySQLSchemaManagerTest.php

+8-24
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
use Doctrine\DBAL\Tests\Functional\Schema\MySQL\PointType;
1616
use Doctrine\DBAL\Tests\TestUtil;
1717
use Doctrine\DBAL\Types\BlobType;
18+
use Doctrine\DBAL\Types\FloatType;
1819
use Doctrine\DBAL\Types\JsonType;
20+
use Doctrine\DBAL\Types\RealFloatType;
1921
use Doctrine\DBAL\Types\Type;
2022
use Doctrine\DBAL\Types\Types;
2123

@@ -370,40 +372,22 @@ public function testListDecimalTypeColumns(): void
370372
self::assertTrue($columns['col_unsigned']->getUnsigned());
371373
}
372374

373-
public function testListFloatTypeColumns(): void
375+
public function testListUnsignedFloatTypeColumns(): void
374376
{
375-
$tableName = 'test_list_float_columns';
377+
$tableName = 'test_unsigned_float_columns';
376378
$table = new Table($tableName);
377379

378-
$table->addColumn('col', Types::FLOAT);
379380
$table->addColumn('col_unsigned', Types::FLOAT, ['unsigned' => true]);
381+
$table->addColumn('col_real_unsigned', Types::REAL, ['unsigned' => true]);
380382

381383
$this->dropAndCreateTable($table);
382384

383385
$columns = $this->schemaManager->listTableColumns($tableName);
384386

385-
self::assertArrayHasKey('col', $columns);
386-
self::assertArrayHasKey('col_unsigned', $columns);
387-
self::assertFalse($columns['col']->getUnsigned());
388-
self::assertTrue($columns['col_unsigned']->getUnsigned());
389-
}
390-
391-
public function testListRealFloatTypeColumns(): void
392-
{
393-
$tableName = 'test_list_real_columns';
394-
$table = new Table($tableName);
395-
396-
$table->addColumn('col', Types::REAL);
397-
$table->addColumn('col_unsigned', Types::REAL, ['unsigned' => true]);
398-
399-
$this->dropAndCreateTable($table);
400-
401-
$columns = $this->schemaManager->listTableColumns($tableName);
402-
403-
self::assertArrayHasKey('col', $columns);
404-
self::assertArrayHasKey('col_unsigned', $columns);
405-
self::assertFalse($columns['col']->getUnsigned());
387+
self::assertInstanceOf(FloatType::class, $columns['col_unsigned']->getType());
388+
self::assertInstanceOf(RealFloatType::class, $columns['col_real_unsigned']->getType());
406389
self::assertTrue($columns['col_unsigned']->getUnsigned());
390+
self::assertTrue($columns['col_real_unsigned']->getUnsigned());
407391
}
408392

409393
public function testJsonColumnType(): void

tests/Functional/Schema/SchemaManagerFunctionalTestCase.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -863,16 +863,19 @@ public function testListTableWithBlob(): void
863863

864864
public function testListTableFloatTypeColumns(): void
865865
{
866-
$table = new Table('test_float_table');
866+
$tableName = 'test_float_columns';
867+
$table = new Table($tableName);
867868
$table->addColumn('col_float', Types::FLOAT);
868869
$table->addColumn('col_real_float', Types::REAL);
869870

870871
$this->dropAndCreateTable($table);
871872

872-
$columns = $this->schemaManager->listTableColumns('test_float_table');
873+
$columns = $this->schemaManager->listTableColumns($tableName);
873874

874875
self::assertInstanceOf(FloatType::class, $columns['col_float']->getType());
875876
self::assertInstanceOf(RealFloatType::class, $columns['col_real_float']->getType());
877+
self::assertFalse($columns['col_float']->getUnsigned());
878+
self::assertFalse($columns['col_real_float']->getUnsigned());
876879
}
877880

878881
/** @param mixed[] $data */

tests/Types/RealFloatTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ protected function setUp(): void
2222

2323
public function testFloatConvertsToPHPValue(): void
2424
{
25-
$result = $this->type->convertToPHPValue('5.5', $this->platform);
26-
self::assertIsFloat($result);
27-
self::assertEquals(5.5, $result);
25+
self::assertEquals(5.5, $this->type->convertToPHPValue('5.5', $this->platform));
2826
}
2927

3028
public function testFloatNullConvertsToPHPValue(): void

0 commit comments

Comments
 (0)