Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janklan committed Sep 24, 2024
1 parent 95e9d33 commit 50ec342
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions tests/Tests/ORM/Functional/Ticket/GH11608/GH11608Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
use Doctrine\ORM\Mapping\UnderscoreNamingStrategy;
use Doctrine\ORM\Tools\SchemaValidator;
use Doctrine\Tests\OrmFunctionalTestCase;
use Generator;
use PHPUnit\Framework\Attributes\DataProvider;

use function var_dump;

class GH11608Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();

$this->useModelSet(self::class);
$this->_em->getConfiguration()->setNamingStrategy(new UnderscoreNamingStrategy());
}
Expand All @@ -28,4 +33,21 @@ public function testOneToManyIndexByErrorDetected(): void
self::assertStringContainsStringIgnoringCase('invalidRightSideEntities is indexed by a field right_side_id_that_doesnt_exist', $errors[0]);
self::assertStringContainsStringIgnoringCase('invalidConnections is indexed by a field arbitrary_value_that_doesnt_exist', $errors[1]);
}

#[DataProvider('provideValidEntitiesCauseNoErrors')]
public function testValidEntitiesCauseNoErrors(string $className): void
{
$validator = new SchemaValidator($this->_em);

$errors = $validator->validateClass($this->_em->getClassMetadata($className));

var_dump($errors);
self::assertEmpty($errors);
}

public static function provideValidEntitiesCauseNoErrors(): Generator
{
yield [ConnectingEntity::class];
yield [RightSideEntity::class];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RightSideEntity
#[GeneratedValue]
public int $id;

#[OneToMany(targetEntity: ConnectingEntity::class, mappedBy: 'rightSide', indexBy: 'left_side_id')]
#[OneToMany(targetEntity: ConnectingEntity::class, mappedBy: 'rightSide', indexBy: 'id')]
public Collection $leftSideEntities;

public function __construct()
Expand Down

0 comments on commit 50ec342

Please sign in to comment.