Skip to content

Commit 96b2cb6

Browse files
committed
Use attribute mapping for mongo when using PHP >= 8
1 parent 4242ac4 commit 96b2cb6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

tests/Gedmo/Mapping/Fixture/Document/User.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,37 @@
1212
namespace Gedmo\Tests\Mapping\Fixture\Document;
1313

1414
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
15+
use Doctrine\ODM\MongoDB\Types\Type;
1516
use Gedmo\Tests\Mapping\Mock\Extension\Encoder\Mapping as Ext;
1617

1718
/**
1819
* @ODM\Document(collection="test_users")
1920
*/
21+
#[ODM\Document(collection: 'test_users')]
2022
class User
2123
{
2224
/**
2325
* @var string|null
2426
*
2527
* @ODM\Id
2628
*/
29+
#[ODM\Id]
2730
private $id;
2831

2932
/**
3033
* @Ext\Encode(type="sha1", secret="xxx")
3134
*
3235
* @ODM\Field(type="string")
3336
*/
37+
#[ODM\Field(type: Type::STRING)]
3438
private ?string $name = null;
3539

3640
/**
3741
* @Ext\Encode(type="md5")
3842
*
3943
* @ODM\Field(type="string")
4044
*/
45+
#[ODM\Field(type: Type::STRING)]
4146
private ?string $password = null;
4247

4348
public function setName(?string $name): void

tests/Gedmo/Tool/BaseTestCaseMongoODM.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ protected function getMockMappedDocumentManager(?EventManager $evm = null, ?Conf
9999
*/
100100
protected function getMetadataDriverImplementation(): MappingDriver
101101
{
102+
if (PHP_VERSION_ID >= 80000) {
103+
return new AttributeDriver();
104+
}
105+
102106
return new AnnotationDriver($_ENV['annotation_reader']);
103107
}
104108

0 commit comments

Comments
 (0)