public function testTypeGuesser(string
$type,
$expected) { $classMetadata =
$this->
createMock(ClassMetadata::
class);
$classMetadata->fieldMappings
['field'
] = true;
$classMetadata->
expects($this->
once())->
method('getTypeOfField'
)->
with('field'
)->
willReturn($type);
$this->
assertEquals($expected,
$this->
getGuesser($classMetadata)->
guessType('TestEntity', 'field'
));
} public static function requiredType() { yield [Types::DATE_IMMUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType',
['input' => 'datetime_immutable'
], Guess::HIGH_CONFIDENCE
)];
yield [Types::DATE_MUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType',
[], Guess::HIGH_CONFIDENCE
)];
yield [Types::TIME_IMMUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType',
['input' => 'datetime_immutable'
], Guess::HIGH_CONFIDENCE
)];
yield [Types::TIME_MUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType',
[], Guess::HIGH_CONFIDENCE
)];
yield [Types::DATETIME_IMMUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType',
['input' => 'datetime_immutable'
], Guess::HIGH_CONFIDENCE
)];
yield [Types::DATETIMETZ_IMMUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType',
['input' => 'datetime_immutable'
], Guess::HIGH_CONFIDENCE
)];
yield [Types::DATETIME_MUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType',
[], Guess::HIGH_CONFIDENCE
)];
yield [Types::DATETIMETZ_MUTABLE,
new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType',
[], Guess::HIGH_CONFIDENCE
)];
}