Skip to content

Commit

Permalink
[GH-8122] Move test from AbstractMappingDriverTest to ClassMetadataFa…
Browse files Browse the repository at this point in the history
…ctoryTest case
  • Loading branch information
beberlei committed Jul 5, 2020
1 parent 64c3f68 commit 775d91c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 123 deletions.
10 changes: 0 additions & 10 deletions tests/Doctrine/Tests/Models/CaseSensitiveDiscriminatorMap/Cube.php

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1080,18 +1080,6 @@ public function testDiscriminatorColumnDefaultName()
$class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class);
$this->assertEquals('dtype', $class->discriminatorColumn['name']);
}

public function testInvalidSubClassCase()
{
class_exists(CaseSensitiveDiscriminatorMap\Cube::class);

$this->expectException(MappingException::class);
$this->expectExceptionMessage('Entity class \'Doctrine\Tests\Models\CaseSensitiveDiscriminatorMap\cube\' used in the discriminator map of class \'Doctrine\Tests\Models\CaseSensitiveDiscriminatorMap\Shape\' does not exist.');

$em = $this->_getTestEntityManager();
$factory = $this->createClassMetadataFactory($em);
$factory->getMetadataFor(CaseSensitiveDiscriminatorMap\Shape::class);
}
}

/**
Expand Down
30 changes: 30 additions & 0 deletions tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,36 @@ public function testInheritsIdGeneratorMappingFromEmbeddable()

$this->assertTrue($userMetadata->isIdGeneratorIdentity());
}

public function testInvalidSubClassCase()
{
$this->expectException(MappingException::class);
$this->expectExceptionMessage('Entity class \'Doctrine\Tests\ORM\Mapping\cube\' used in the discriminator map of class \'Doctrine\Tests\ORM\Mapping\Shape\' does not exist.');

$cmf = new ClassMetadataFactory();
$driver = $this->createAnnotationDriver([__DIR__]);
$em = $this->_createEntityManager($driver);
$cmf->setEntityManager($em);

$userMetadata = $cmf->getMetadataFor(Shape::class);
}
}

/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorMap({"cube" = cube::class})
* @DiscriminatorColumn(name="discr", length=32, type="string")
*/
abstract class Shape
{
/** @Id @Column(type="string") @GeneratedValue(strategy="AUTO") */
public $id;
}

/** @Entity */
final class Cube extends Shape
{
}

/* Test subject class with overridden factory method for mocking purposes */
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 775d91c

Please sign in to comment.