From 6ae38c984398a5ce61eee261d1ba91508a1cf89f Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Sat, 21 Nov 2026 00:22:41 +0400 Subject: [PATCH 1/2] test(schema): cover the deprecated RegistryModifier::isType() The method is protected and has no caller in the package, but subclasses written before v1.2 may still call it. Assisted-By: Claude Opus 5.5 --- .../Common/Schema/RegistryModifierTest.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/Feature/Common/Schema/RegistryModifierTest.php b/tests/Feature/Common/Schema/RegistryModifierTest.php index be4f1db..f9c2861 100644 --- a/tests/Feature/Common/Schema/RegistryModifierTest.php +++ b/tests/Feature/Common/Schema/RegistryModifierTest.php @@ -12,6 +12,7 @@ use Cycle\ORM\Schema\GeneratedField; use Cycle\ORM\SchemaInterface; use Cycle\Schema\Definition\Entity; +use Cycle\Schema\Definition\Field; use Cycle\Schema\Registry; use Cycle\Testing\Database\DatabaseTestCase; use Ramsey\Uuid\Uuid; @@ -327,6 +328,28 @@ public function testCustomTypecastNotOverridden(): void Assert::same($field->getTypecast(), ['foo', 'bar']); } + #[Test] + #[DataSet(['datetime', 'datetime', 'datetime'], 'datetime field over a datetime column')] + #[DataSet(['datetime', 'string', 'datetime'], 'datetime field over a string column')] + #[DataSet(['int', 'integer', 'int'], 'integer column')] + #[DataSet(['uuid', 'uuid', 'uuid'], 'uuid field over a uuid column')] + #[DataSet(['uuid', 'string', 'uuid'], 'uuid field over a string column')] + #[DataSet(['string', 'string', 'string'], 'any other type')] + public function testDeprecatedIsTypeMatches(string $type, string $columnType, string $fieldType): void + { + Assert::true($this->checkType($type, $columnType, $fieldType)); + } + + #[Test] + #[DataSet(['datetime', 'string', 'string'], 'datetime')] + #[DataSet(['int', 'string', 'int'], 'integer')] + #[DataSet(['uuid', 'string', 'string'], 'uuid')] + #[DataSet(['string', 'integer', 'string'], 'any other type')] + public function testDeprecatedIsTypeMismatches(string $type, string $columnType, string $fieldType): void + { + Assert::false($this->checkType($type, $columnType, $fieldType)); + } + #[BeforeTest] protected function setUp(): void { @@ -338,4 +361,23 @@ protected function setUp(): void $this->modifier = new RegistryModifier($this->registry, self::ROLE_TEST); } + + /** + * Calls the deprecated protected `isType()` the way a subclass would, on a field linked to a column of its name. + */ + private function checkType(string $type, string $columnType, string $fieldType): bool + { + $entity = $this->registry->getEntity(self::ROLE_TEST); + $this->registry->getTableSchema($entity)->column('value')->type($columnType); + $entity->getFields()->set('value', (new Field())->setColumn('value')->setType($fieldType)); + + $modifier = new class($this->registry, self::ROLE_TEST) extends RegistryModifier { + public function check(string $type, string $fieldName, string $columnName): bool + { + return $this->isType($type, $fieldName, $columnName); + } + }; + + return $modifier->check($type, 'value', 'value'); + } } From 11737a4823889237f5c70333b48f835167a57674 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Sat, 21 Nov 2026 00:40:12 +0400 Subject: [PATCH 2/2] test(schema): reject a reused field bound to another column The isType() tests add an equivalent mutant (the integer branch returns what the fallback would), which took MSI under the 97% gate; these cases kill four escaped validateColumnName() removals. Assisted-By: Claude Opus 5.5 --- .../Common/Schema/RegistryModifierTest.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Feature/Common/Schema/RegistryModifierTest.php b/tests/Feature/Common/Schema/RegistryModifierTest.php index f9c2861..d9f3f45 100644 --- a/tests/Feature/Common/Schema/RegistryModifierTest.php +++ b/tests/Feature/Common/Schema/RegistryModifierTest.php @@ -274,6 +274,26 @@ public function testExistingFieldOfSameTypeIsReused(string $method): void Assert::same($column->getName(), 'value_column'); } + #[Test] + #[DataSet(['addIntegerColumn'], 'integer')] + #[DataSet(['addBigIntegerColumn'], 'big integer')] + #[DataSet(['addDatetimeColumn'], 'datetime')] + #[DataSet(['addStringColumn'], 'string')] + #[DataSet(['addSnowflakeColumn'], 'snowflake')] + #[DataSet(['addUlidColumn'], 'ulid')] + #[DataSet(['addUuidColumn'], 'uuid')] + public function testExistingFieldOfSameTypeOnOtherColumnIsRejected(string $method): void + { + $this->modifier->{$method}('value_column', 'value'); + + Expect::exception(BehaviorCompilationException::class)->withMessage( + 'Ambiguous column name definition. ' + . 'The `value` field already linked with the `value_column` column but the behavior expects `other_column`.', + ); + + $this->modifier->{$method}('other_column', 'value'); + } + #[Test] #[DataSet(['addIntegerColumn', 'Field value must be of type integer.'], 'integer')] #[DataSet(['addStringColumn', 'Field value must be of type string.'], 'string')]