public function columnNamesAreBuiltCorrectly()
{
$expectedTitleMapping = ['fieldName' => 'title', 'columnName' => 'title', 'targetEntity' => 'string', 'nullable' => false, 'type' => 'string'];
$expectedImageAssociationMapping = ['fieldName' => 'image', 'columnName' => 'image', 'joinColumns' => [0 => ['name' => 'image', 'referencedColumnName' => 'persistence_object_identifier', 'unique' => true]], 'joinColumnFieldNames' => ['image' => 'image']];
$expectedCommentAssociationMapping = ['fieldName' => 'comment', 'columnName' => 'comment', 'joinColumns' => [0 => ['name' => 'comment', 'referencedColumnName' => 'persistence_object_identifier', 'unique' => true, 'nullable' => true, 'onDelete' => 'SET NULL', 'columnDefinition' => null]], 'sourceEntity' => Fixtures\Post::class, 'sourceToTargetKeyColumns' => ['comment' => 'persistence_object_identifier'], 'joinColumnFieldNames' => ['comment' => 'comment'], 'targetToSourceKeyColumns' => ['persistence_object_identifier' => 'comment']];
$classMetadata = new ClassMetadata(Fixtures\Post::class);
$driver = $this->objectManager->get(FlowAnnotationDriver::class);
$driver->loadMetadataForClass(Fixtures\Post::class, $classMetadata);
$this->assertEquals($expectedTitleMapping, $classMetadata->getFieldMapping('title'), 'mapping for "title" not as expected');
$imageAssociationMapping = $classMetadata->getAssociationMapping('image');
$thumbnailAssociationMapping = $classMetadata->getAssociationMapping('thumbnail');
foreach (array_keys($expectedImageAssociationMapping) as $key) {
$this->assertEquals($expectedImageAssociationMapping[$key], $imageAssociationMapping[$key], 'mapping for "image" not as expected');
$this->assertNotEquals($expectedImageAssociationMapping[$key], $thumbnailAssociationMapping[$key], 'mapping for "thumbnail" not as expected');
}
$commentAssociationMapping = $classMetadata->getAssociationMapping('comment');
$this->assertEquals(1, count($commentAssociationMapping['joinColumns']));
foreach (array_keys($expectedCommentAssociationMapping) as $key) {
$this->assertEquals($expectedCommentAssociationMapping[$key], $commentAssociationMapping[$key], 'mapping for "comment" not as expected');
}
}