8000 Add test for mapping type detection for PHP files · symfony/symfony@c286e53 · GitHub
[go: up one dir, main page]

Skip to content

Commit c286e53

Browse files
committed
Add test for mapping type detection for PHP files
1 parent 9fbc243 commit c286e53

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,23 @@ public function testFixManagersAutoMappings(array $originalEm1, array $originalE
171171
], $expectedEm2));
172172
}
173173

174+
public function testMappingTypeDetection()
175+
{
176+
$container = $this->createContainer();
177+
178+
$reflection = new \ReflectionClass(\get_class($this->extension));
179+
$method = $reflection->getMethod('detectMappingType');
180+
$method->setAccessible(true);
181+
182+
// The ordinary fixtures contain annotation
183+
$mappingType = $method->invoke($this->extension, __DIR__ . '/../Fixtures', $container);
184+
$this->assertSame($mappingType, 'annotation');
185+
186+
// In the attribute folder, attributes are used
187+
$mappingType = $method->invoke($this->extension, __DIR__ . '/../Fixtures/Attribute', $container);
188+
$this->assertSame($mappingType, \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute');
189+
}
190+
174191
public function providerBasicDrivers()
175192
{
176193
return [
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\Fixtures\Attribute;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Entity;
16+
use Doctrine\ORM\Mapping\Id;
17+
18+
#[Entity]
19+
class UuidIdEntity
20+
{
21+
#[Id]
22+
#[Column("uuid")]
23+
protected $id;
24+
25+
public function __construct($id)
26+
{
27+
$this->id = $id;
28+
}
29+
}

0 commit comments

Comments
 (0)
0