File tree Expand file tree Collapse file tree 4 files changed +33
-4
lines changed
src/DoctrineORMModule/Paginator/Adapter
test/DoctrineORMModuleTest Expand file tree Collapse file tree 4 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 5
5
namespace DoctrineORMModule \Paginator \Adapter ;
6
6
7
7
use Doctrine \ORM \Tools \Pagination \Paginator ;
8
+ use JsonSerializable ;
8
9
use Laminas \Paginator \Adapter \AdapterInterface ;
9
10
10
11
/**
11
12
* Paginator adapter for the Laminas\Paginator component
12
13
*/
13
- class DoctrinePaginator implements AdapterInterface
14
+ class DoctrinePaginator implements AdapterInterface, JsonSerializable
14
15
{
15
16
/** @var Paginator */
16
17
protected $ paginator ;
@@ -55,4 +56,15 @@ public function count()
55
56
{
56
57
return $ this ->paginator ->count ();
57
58
}
59
+
60
+ /**
61
+ * @return array{select: string, count_select: int}
62
+ */
63
+ public function jsonSerialize (): array
64
+ {
65
+ return [
66
+ 'select ' => $ this ->paginator ->getQuery ()->getSQL (),
67
+ 'count_select ' => $ this ->paginator ->count (),
68
+ ];
69
+ }
58
70
}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class FormEntity
20
20
protected $ id ;
21
21
22
22
/**
23
- * @ORM\Column(type="bool ")
23
+ * @ORM\Column(type="boolean ")
24
24
*
25
25
* @var bool
26
26
*/
Original file line number Diff line number Diff line change 6
6
7
7
/**
8
8
* @ORM\Entity
9
- * @ORM\Table(name="doctrine_orm_module_form_entity ")
9
+ * @ORM\Table(name="doctrine_orm_module_form_entity_issue237 ")
10
10
*/
11
11
class Issue237
12
12
{
Original file line number Diff line number Diff line change 12
12
use DoctrineORMModuleTest \Assets \Fixture \TestFixture ;
13
13
use DoctrineORMModuleTest \Framework \TestCase ;
14
14
15
+ use function class_exists ;
15
16
use function count ;
16
17
17
- class AdapterTestIgnore extends TestCase
18
+ class AdapterTest extends TestCase
18
19
{
19
20
/** @var QueryBuilder */
20
21
protected $ queryBuilder ;
@@ -29,6 +30,12 @@ public function setUp(): void
29
30
{
30
31
parent ::setUp ();
31
32
33
+ if (! class_exists (FixtureLoader::class)) {
34
+ $ this ->markTestIncomplete (
35
+ 'DataFixtures must be installed to run this test. '
36
+ );
37
+ }
38
+
32
39
$ this ->createDb ();
33
40
$ loader = new FixtureLoader ();
34
41
$ loader ->addFixture (new TestFixture ());
@@ -82,4 +89,14 @@ public function testGetsItemsAtOffsetTen(): void
82
89
$ this ->assertEquals ($ expectedItem , $ actual [$ key ]);
83
90
}
84
91
}
92
+
93
+ public function testJsonSerialize (): void
94
+ {
95
+ $ result = $ this ->paginatorAdapter ->jsonSerialize ();
96
+
97
+ $ this ->assertArrayHasKey ('select ' , $ result );
98
+ $ this ->assertArrayHasKey ('count_select ' , $ result );
99
+ $ this ->assertSame ($ result ['count_select ' ], $ this ->paginator ->count ());
100
+ $ this ->assertSame ($ result ['select ' ], $ this ->paginator ->getQuery ()->getSQL ());
101
+ }
85
102
}
You can’t perform that action at this time.
0 commit comments