Skip to content

Commit 9907f4e

Browse files
committed
Remove sorting
1 parent fe79ae1 commit 9907f4e

6 files changed

Lines changed: 19 additions & 52 deletions

File tree

src/Subscription/Controller/SubscriberController.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,6 @@ enum: ['true', 'false', '0', '1'],
9898
example: '1'
9999
)
100100
),
101-
new OA\Parameter(
102-
name: 'sort_by',
103-
description: 'Column to sort by',
104-
in: 'query',
105-
required: false,
106-
schema: new OA\Schema(type: 'string', example: 'id')
107-
),
108-
new OA\Parameter(
109-
name: 'sort_direction',
110-
description: 'Sort direction',
111-
in: 'query',
112-
required: false,
113-
schema: new OA\Schema(
114-
type: 'string',
115-
enum: ['asc', 'desc'],
116-
example: 'desc'
117-
)
118-
),
119101
new OA\Parameter(
120102
name: 'find_column',
121103
description: 'Column to search in (requires find_value)',

src/Subscription/Request/SubscribersFilterRequest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ class SubscribersFilterRequest implements RequestInterface
2222
)]
2323
public mixed $isBlacklisted = null;
2424

25-
#[Assert\Choice(
26-
choices: ['email', 'confirmedAt', 'createdAt'],
27-
message: 'Invalid sortBy value'
28-
)]
29-
public ?string $sortBy = null;
30-
31-
#[Assert\Choice(
32-
choices: ['asc', 'desc'],
33-
message: 'sortDirection must be asc or desc'
34-
)]
35-
public ?string $sortDirection = null;
36-
3725
#[Assert\Choice(
3826
choices: ['email', 'foreignKey', 'uniqueId'],
3927
message: 'Invalid findColumn value'
@@ -48,8 +36,6 @@ public function getDto(): SubscriberFilter
4836
return new SubscriberFilter(
4937
isConfirmed: $this->normalizeBoolean($this->isConfirmed),
5038
isBlacklisted: $this->normalizeBoolean($this->isBlacklisted),
51-
sortBy: $this->sortBy,
52-
sortDirection: $this->sortDirection,
5339
findColumn: $this->findColumn,
5440
findValue: $this->findColumn ? $this->findValue : null,
5541
);

tests/Helpers/DummyDomainModel.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpList\RestBundle\Tests\Helpers;
6+
7+
use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel;
8+
9+
class DummyDomainModel implements DomainModel
10+
{
11+
public function __construct(
12+
public int $id,
13+
public string $name,
14+
) {
15+
}
16+
}

tests/Helpers/DummyPaginatableRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public function getFilteredAfterId(int $lastId, int $limit, ?FilterRequestInterf
1515
{
1616
return new PaginatedResult(
1717
[
18-
(object)['id' => 1, 'name' => 'Item 1'],
19-
(object)['id' => 2, 'name' => 'Item 2'],
18+
new DummyDomainModel(1, 'Item 1'),
19+
new DummyDomainModel(2, 'Item 2'),
2020
],
2121
2,
2222
10,

tests/Unit/Common/Service/Provider/PaginatedDataProviderTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace PhpList\RestBundle\Tests\Unit\Common\Service\Provider;
66

77
use Doctrine\ORM\EntityManagerInterface;
8-
use PhpList\Core\Domain\Common\Model\PaginatedResult;
98
use PhpList\RestBundle\Common\Dto\CursorPaginationResult;
109
use PhpList\RestBundle\Common\Request\PaginationCursorRequest;
1110
use PhpList\RestBundle\Common\Serializer\CursorPaginationNormalizer;
@@ -37,17 +36,7 @@ public function testGetPaginatedListSuccess(): void
3736
$entityManager->method('getRepository')->willReturn($repository);
3837
$repository->expects($this->once())
3938
->method('getFilteredAfterId')
40-
->with(0, 2)
41-
->willReturn(
42-
new PaginatedResult([
43-
(object)['id' => 1, 'name' => 'Item 1'],
44-
(object)['id' => 2, 'name' => 'Item 2'],
45-
],
46-
2,
47-
10,
48-
2,
49-
)
50-
);
39+
->with(0, 2);
5140

5241
$entityManager->method('getRepository')
5342
->willReturn($repository);

tests/Unit/Subscription/Request/SubscribersFilterRequestTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public function testGetDtoReturnsCorrectDtoWithAllValues(): void
1515
$request = new SubscribersFilterRequest();
1616
$request->isConfirmed = 'true';
1717
$request->isBlacklisted = 'false';
18-
$request->sortBy = 'email';
19-
$request->sortDirection = 'desc';
2018
$request->findColumn = 'email';
2119
$request->findValue = 'test@example.com';
2220

@@ -25,8 +23,6 @@ public function testGetDtoReturnsCorrectDtoWithAllValues(): void
2523
$this->assertInstanceOf(SubscriberFilter::class, $dto);
2624
$this->assertTrue($dto->getIsConfirmed());
2725
$this->assertFalse($dto->getIsBlacklisted());
28-
$this->assertEquals('email', $dto->getSortBy());
29-
$this->assertEquals('desc', $dto->getSortDirection());
3026
$this->assertEquals('email', $dto->getFindColumn());
3127
$this->assertEquals('test@example.com', $dto->getFindValue());
3228
}
@@ -64,8 +60,6 @@ public function testGetDtoReturnsCorrectDtoWithNullValues(): void
6460
$this->assertInstanceOf(SubscriberFilter::class, $dto);
6561
$this->assertNull($dto->getIsConfirmed());
6662
$this->assertNull($dto->getIsBlacklisted());
67-
$this->assertNull($dto->getSortBy());
68-
$this->assertNull($dto->getSortDirection());
6963
$this->assertNull($dto->getFindColumn());
7064
$this->assertNull($dto->getFindValue());
7165
}

0 commit comments

Comments
 (0)