Skip to content

Commit 46ff8a9

Browse files
committed
Fix deprecations findAll wants named params
1 parent e5fe320 commit 46ff8a9

File tree

8 files changed

+48
-31
lines changed

8 files changed

+48
-31
lines changed

src/Controller/NotificationsController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,15 @@ public function data_tables(): Response
108108
$pagedParams['limit'] = intval($this->request->getQuery('iDisplayLength'));
109109
$pagedParams['offset'] = intval($this->request->getQuery('iDisplayStart'));
110110

111-
$rows = $this->Notifications->find('all', $pagedParams);
111+
$rows = $this->Notifications->find(
112+
'all',
113+
contain: $pagedParams['contain'],
114+
fields: $pagedParams['fields'],
115+
conditions: $pagedParams['conditions'],
116+
order: $pagedParams['order'],
117+
limit: $pagedParams['limit'],
118+
offset: $pagedParams['offset'],
119+
);
112120
$totalFiltered = $this->Notifications->find(
113121
'all',
114122
conditions: [

src/Controller/ReportsController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,14 @@ public function data_tables(): ?Response
186186
$pagedParams['offset'] = (int) $this->request->getQuery('iDisplayStart');
187187

188188
$rows = $this->findAllDataTable(
189-
$this->Reports->find('all', $pagedParams)->innerJoin(
189+
$this->Reports->find(
190+
'all',
191+
fields: $pagedParams['fields'],
192+
conditions: $pagedParams['conditions'],
193+
order: $pagedParams['order'],
194+
limit: $pagedParams['limit'],
195+
offset: $pagedParams['offset'],
196+
)->innerJoin(
190197
['incidents' => $subquery],
191198
['incidents.report_id = Reports.id']
192199
)

src/Model/Table/ReportsTable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ public function getRelatedByField(
221221
'conditions' => [
222222
'NOT' => ['Incidents.' . $fieldName . ' is null'],
223223
],
224-
'limit' => $limit,
225224
];
226225

227226
if ($related) {
@@ -232,7 +231,11 @@ public function getRelatedByField(
232231
$queryDetails['conditions'][] = ['Incidents.created >=' => $timeLimit];
233232
}
234233

235-
$groupedCount = TableRegistry::getTableLocator()->get('Incidents')->find('all', $queryDetails);
234+
$groupedCount = TableRegistry::getTableLocator()->get('Incidents')->find(
235+
'all',
236+
conditions: $queryDetails['conditions'],
237+
limit: $limit,
238+
);
236239

237240
/* Ommit version number in case of browser and server_software fields.
238241
* In case of browser field, version number is seperated by space,

tests/TestCase/Controller/IncidentsControllerTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ public function testView(): void
5656
public function testJson(): void
5757
{
5858
$this->get('/incidents/json/1');
59+
$this->assertSame(200, $this->_response->getStatusCode(), 'The reponse code should be 200 !');
5960
$incident = json_decode($this->_response->getBody(), true);
61+
$this->assertNotNull($incident, 'The incident should be an array !');
62+
6063
$expected = [
6164
'id' => 1,
6265
'error_name' => 'Lorem ipsum dolor sit amet',
@@ -102,8 +105,10 @@ public function testCreate(): void
102105

103106
$report = $this->Reports->find(
104107
'all',
105-
['order' => 'Reports.created desc']
106-
)->all()->first();
108+
order: ['Reports.created desc']
109+
)->first();
110+
$this->assertNotNull($report, 'The report should be created !');
111+
107112
$subject = 'A new report has been submitted '
108113
. 'on the Error Reporting Server: '
109114
. $report['id'];
@@ -123,7 +128,7 @@ public function testCreate(): void
123128

124129
$report = $this->Reports->find(
125130
'all',
126-
['order' => 'Reports.created desc']
131+
order: ['Reports.created desc']
127132
)->all()->first();
128133
$this->Reports->id = $report['id'];
129134
$incidents = $this->Reports->getIncidents();
@@ -158,7 +163,7 @@ public function testCreate(): void
158163

159164
$report = $this->Reports->find(
160165
'all',
161-
['order' => 'Reports.created desc']
166+
order: ['Reports.created desc']
162167
)->all()->first();
163168
$subject = 'A new report has been submitted '
164169
. 'on the Error Reporting Server: '

tests/TestCase/Controller/NotificationsControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testMassAction(): void
5757
]
5858
);
5959

60-
$notifications = $this->Notifications->find('all', ['fields' => ['Notifications.id']]);
60+
$notifications = $this->Notifications->find('all', fields: ['Notifications.id']);
6161
$this->assertInstanceOf('Cake\ORM\Query', $notifications);
6262
$actual = $notifications->enableHydration(false)->toArray();
6363
$expected = [
@@ -71,7 +71,7 @@ public function testMassAction(): void
7171
['mark_all' => 1]
7272
);
7373

74-
$notifications = $this->Notifications->find('all', ['fields' => ['Notifications.id']]);
74+
$notifications = $this->Notifications->find('all', fields: ['Notifications.id']);
7575
$this->assertInstanceOf('Cake\ORM\Query', $notifications);
7676
$actual = $notifications->enableHydration(false)->toArray();
7777
$expected = [];

tests/TestCase/Model/Table/IncidentsTableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public function testCreateIncidentFromBugReport(): void
406406

407407
$incident = $this->Incidents->get($result['incidents'][0]);
408408
// check the incident has been reported under the same 'Report'
409-
$result = TableRegistry::getTableLocator()->get('Incidents')->find('all', ['conditions' => ['report_id = ' . $incident->report_id]]);
409+
$result = TableRegistry::getTableLocator()->get('Incidents')->find('all', conditions: ['report_id = ' . $incident->report_id]);
410410
$result = $result->enableHydration(false)->toArray();
411411
$this->assertEquals(2, count($result));
412412

@@ -430,7 +430,7 @@ public function testCreateIncidentFromBugReport(): void
430430

431431
// check the incidents have been reported under the same 'Report's
432432
$incident = $this->Incidents->get($result['incidents'][0]);
433-
$result = TableRegistry::getTableLocator()->get('Incidents')->find('all', ['conditions' => ['report_id = ' . $incident->report_id]]);
433+
$result = TableRegistry::getTableLocator()->get('Incidents')->find('all', conditions: ['report_id = ' . $incident->report_id]);
434434
$result = $result->enableHydration(false)->toArray();
435435
$this->assertEquals(2, count($result));
436436

tests/TestCase/Model/Table/NotificationsTableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testAddNotifications(): void
4141
$devs = $developer->find('all');
4242
$devs = $devs->enableHydration(false)->toArray();
4343
$this->Notifications->addNotifications($report_id);
44-
$notifs = $this->Notifications->find('all', ['conditions' => ['report_id' => $report_id]]);
44+
$notifs = $this->Notifications->find('all', conditions: ['report_id' => $report_id]);
4545
$notifs = $notifs->enableHydration(false)->toArray();
4646
$this->assertEquals(count($notifs), count($devs));
4747
}

tests/TestCase/Shell/SyncGithubIssueStatesShellTest.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ public function testExecute(): void
6262
// Fetch all linked reports
6363
$reports = $Reports->find(
6464
'all',
65-
[
66-
'conditions' => [
67-
'sourceforge_bug_id IS NOT NULL',
68-
'NOT' => ['status' => 'resolved'],
69-
],
70-
]
65+
conditions: [
66+
'sourceforge_bug_id IS NOT NULL',
67+
'NOT' => ['status' => 'resolved'],
68+
],
7169
);
7270
$this->assertEquals(3, $reports->count());
7371

@@ -78,24 +76,20 @@ public function testExecute(): void
7876
// Fetch all linked reports
7977
$reports = $Reports->find(
8078
'all',
81-
[
82-
'conditions' => [
83-
'sourceforge_bug_id IS NOT NULL',
84-
'NOT' => ['status' => 'resolved'],
85-
],
86-
]
79+
conditions: [
80+
'sourceforge_bug_id IS NOT NULL',
81+
'NOT' => ['status' => 'resolved'],
82+
],
8783
);
8884
$this->assertEquals(2, $reports->count());
8985

9086
// Fetch all closed reports
9187
$reports = $Reports->find(
9288
'all',
93-
[
94-
'conditions' => [
95-
'sourceforge_bug_id IS NOT NULL',
96-
'status' => 'resolved',
97-
],
98-
]
89+
conditions: [
90+
'sourceforge_bug_id IS NOT NULL',
91+
'status' => 'resolved',
92+
],
9993
);
10094
$this->assertEquals(1, $reports->count());
10195
$report5 = $Reports->get(4);

0 commit comments

Comments
 (0)