Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ class RamseyUuidBinaryDevice
#[ORM\Column(type: 'uuid_binary', unique: true)]
public UuidInterface $id;

public function __construct(?UuidInterface $id = null)
#[ORM\Column(type: 'uuid_binary')]
public UuidInterface $externalId;

public function __construct(?UuidInterface $id = null, ?UuidInterface $externalId = null)
{
$this->id = $id ?? Uuid::uuid7();
$this->externalId = $externalId ?? Uuid::uuid7();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
'myDevice' => new QueryParameter(
filter: new UuidBinaryFilter(),
),
'myDeviceExternalIdAlias' => new QueryParameter(
filter: new UuidBinaryFilter(),
property: 'myDevice.externalId',
),
]
),
new Post(),
Expand Down
6 changes: 5 additions & 1 deletion tests/Fixtures/TestBundle/Entity/Uuid/RamseyUuidDevice.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ class RamseyUuidDevice
#[ORM\Column(type: 'uuid', unique: true)]
public UuidInterface $id;

public function __construct(?UuidInterface $id = null)
#[ORM\Column(type: 'uuid')]
public UuidInterface $externalId;

public function __construct(?UuidInterface $id = null, ?UuidInterface $externalId = null)
{
$this->id = $id ?? Uuid::uuid7();
$this->externalId = $externalId ?? Uuid::uuid7();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
'myDevice' => new QueryParameter(
filter: new UuidFilter(),
),
'myDeviceExternalIdAlias' => new QueryParameter(
filter: new UuidFilter(),
property: 'myDevice.externalId',
),
]
),
new Post(),
Expand Down
6 changes: 5 additions & 1 deletion tests/Fixtures/TestBundle/Entity/Uuid/SymfonyUlidDevice.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ class SymfonyUlidDevice
#[ORM\Column(type: 'ulid', unique: true)]
public Ulid $id;

public function __construct(?Ulid $id = null)
#[ORM\Column(type: 'ulid')]
public Ulid $externalId;

public function __construct(?Ulid $id = null, ?Ulid $externalId = null)
{
$this->id = $id ?? new Ulid();
$this->externalId = $externalId ?? new Ulid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
'myDevice' => new QueryParameter(
filter: new UlidFilter(),
),
'myDeviceExternalIdAlias' => new QueryParameter(
filter: new UlidFilter(),
property: 'myDevice.externalId',
),
]
),
new Post(),
Expand Down
6 changes: 5 additions & 1 deletion tests/Fixtures/TestBundle/Entity/Uuid/SymfonyUuidDevice.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ class SymfonyUuidDevice
#[ORM\Column(type: 'symfony_uuid', unique: true)]
public Uuid $id;

public function __construct(?Uuid $id = null)
#[ORM\Column(type: 'symfony_uuid')]
public Uuid $externalId;

public function __construct(?Uuid $id = null, ?Uuid $externalId = null)
{
$this->id = $id ?? Uuid::v7();
$this->externalId = $externalId ?? Uuid::v7();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
'myDevice' => new QueryParameter(
filter: new UuidFilter(),
),
'myDeviceExternalIdAlias' => new QueryParameter(
filter: new UuidFilter(),
property: 'myDevice.externalId',
),
]
),
new Post(),
Expand Down
35 changes: 35 additions & 0 deletions tests/Functional/Uuid/UuidFilterBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,41 @@ public function testGetOpenApiDescription(): void
);
}

public function testSearchFilterByUuidNested(): void
{
$this->recreateSchema(static::getResources());

$manager = $this->getManager();
$manager->persist($fooDevice = $this->createDevice());
$manager->persist($barDevice = $this->createDevice());
$manager->persist($this->createDeviceEndpoint(null, $fooDevice));
$manager->persist($expectedDeviceEndpoint = $this->createDeviceEndpoint(null, $barDevice));
$manager->flush();

$response = self::createClient()->request('GET', '/'.$this->getUrlPrefix().'_device_endpoints', [
'query' => [
'myDeviceExternalIdAlias' => (string) $expectedDeviceEndpoint->myDevice->externalId,
],
]);

self::assertResponseIsSuccessful();
$json = $response->toArray();

self::assertArraySubset(['hydra:totalItems' => 1], $json);
self::assertArraySubset(
[
'hydra:member' => [
[
'@id' => '/'.$this->getUrlPrefix().'_device_endpoints/'.$expectedDeviceEndpoint->id,
'@type' => $this->geTypePrefix().'DeviceEndpoint',
'id' => (string) $expectedDeviceEndpoint->id,
],
],
],
$json
);
}

protected function tearDown(): void
{
if ($this->isMongoDB()) {
Expand Down
Loading