From 30f19b1db4aa103470fb2dc7fb7068601da5acfc Mon Sep 17 00:00:00 2001 From: Christian Kolb Date: Sun, 9 Jun 2024 14:26:54 +0200 Subject: [PATCH] Add test for weekdays type --- infection.json5 | 10 +++++ tests/Doctrine/WeekdaysTypeTest.php | 63 +++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/Doctrine/WeekdaysTypeTest.php diff --git a/infection.json5 b/infection.json5 index 64fc377..6c3e24c 100644 --- a/infection.json5 +++ b/infection.json5 @@ -12,6 +12,16 @@ "DigitalCraftsman\\DateTimePrecision\\Moment", ] }, + "IncrementInteger": { + "ignore": [ + "DigitalCraftsman\\DateTimePrecision\\Doctrine\\WeekdaysType::convertToPHPValue" + ] + }, + "DecrementInteger": { + "ignore": [ + "DigitalCraftsman\\DateTimePrecision\\Doctrine\\WeekdaysType::convertToPHPValue" + ] + } }, "minMsi": 100, "minCoveredMsi": 100 diff --git a/tests/Doctrine/WeekdaysTypeTest.php b/tests/Doctrine/WeekdaysTypeTest.php new file mode 100644 index 0000000..14cb373 --- /dev/null +++ b/tests/Doctrine/WeekdaysTypeTest.php @@ -0,0 +1,63 @@ +convertToDatabaseValue($weekdays, $platform); + $convertedValue = $doctrineType->convertToPHPValue($databaseValue, $platform); + + // -- Assert + self::assertSame($expectedDatabaseValue, $databaseValue); + self::assertEquals($weekdays, $convertedValue); + } + + /** + * @test + * + * @covers ::convertToDatabaseValue + * @covers ::convertToPHPValue + */ + public function convert_from_and_to_weekdays_php_value_works_with_null(): void + { + // -- Arrange + $doctrineType = new WeekdaysType(); + $platform = new PostgreSQLPlatform(); + + // -- Act + $databaseValue = $doctrineType->convertToDatabaseValue(null, $platform); + $phpValue = $doctrineType->convertToPHPValue($databaseValue, $platform); + + // -- Assert + self::assertNull($phpValue); + } +}