Skip to content

Commit

Permalink
Use proper arguments in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Jun 1, 2021
1 parent 01ab049 commit 251a855
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
use Documents\Address;
use Documents\Album;
use Documents\Bars\Bar;
use Documents\CmsGroup;
use Documents\CmsUser;
use Documents\CustomRepository\Repository;
use Documents\SpecialUser;
use Documents\User;
use Documents\UserName;
Expand Down Expand Up @@ -154,7 +156,7 @@ public function testMapManyToManyJoinTableDefaults()
$cm->mapManyEmbedded(
[
'fieldName' => 'groups',
'targetDocument' => 'CmsGroup',
'targetDocument' => CmsGroup::class,
]
);

Expand Down Expand Up @@ -236,15 +238,15 @@ public function testDuplicateFieldAndAssocationMapping1()
{
$cm = new ClassMetadata(CmsUser::class);
$cm->mapField(['fieldName' => 'name', 'type' => Type::STRING]);
$cm->mapOneEmbedded(['fieldName' => 'name', 'targetDocument' => 'CmsUser']);
$cm->mapOneEmbedded(['fieldName' => 'name', 'targetDocument' => CmsUser::class]);

$this->assertEquals('one', $cm->fieldMappings['name']['type']);
}

public function testDuplicateFieldAndAssocationMapping2()
{
$cm = new ClassMetadata(CmsUser::class);
$cm->mapOneEmbedded(['fieldName' => 'name', 'targetDocument' => 'CmsUser']);
$cm->mapOneEmbedded(['fieldName' => 'name', 'targetDocument' => CmsUser::class]);
$cm->mapField(['fieldName' => 'name', 'columnName' => 'name', 'type' => 'string']);

$this->assertEquals('string', $cm->fieldMappings['name']['type']);
Expand Down Expand Up @@ -416,16 +418,16 @@ public function testSetFieldValueWithProxy()

public function testSetCustomRepositoryClass()
{
$cm = new ClassMetadata('Doctrine\ODM\MongoDB\Tests\Mapping\ClassMetadataTest');
$cm = new ClassMetadata(self::class);
$cm->namespace = 'Doctrine\ODM\MongoDB\Tests\Mapping';

$cm->setCustomRepositoryClass('TestCustomRepositoryClass');
$cm->setCustomRepositoryClass(Repository::class);

$this->assertEquals('TestCustomRepositoryClass', $cm->customRepositoryClassName);
$this->assertEquals(Repository::class, $cm->customRepositoryClassName);

$cm->setCustomRepositoryClass('Doctrine\ODM\MongoDB\Tests\Mapping\TestCustomRepositoryClass');
$cm->setCustomRepositoryClass(TestCustomRepositoryClass::class);

$this->assertEquals('Doctrine\ODM\MongoDB\Tests\Mapping\TestCustomRepositoryClass', $cm->customRepositoryClassName);
$this->assertEquals(TestCustomRepositoryClass::class, $cm->customRepositoryClassName);
}

public function testEmbeddedAssociationsAlwaysCascade()
Expand Down Expand Up @@ -636,9 +638,19 @@ public function testAddInheritedAssociationMapping()

$mapping = [
'fieldName' => 'assoc',
'name' => 'assoc',
'reference' => true,
'type' => 'one',
'storeAs' => ClassMetadata::REFERENCE_STORE_AS_ID,
'isCascadeRemove' => false,
'isCascadePersist' => false,
'isCascadeRefresh' => false,
'isCascadeMerge' => false,
'isCascadeDetach' => false,
'isOwningSide' => false,
'isInverseSide' => false,
'targetDocument' => null,
'association' => ClassMetadata::REFERENCE_ONE,
];

$cm->addInheritedAssociationMapping($mapping);
Expand Down

0 comments on commit 251a855

Please sign in to comment.