Skip to content

Commit 612cef1

Browse files
authored
Merge pull request #113 from FriendsOfCake/3.x-deprecations
Fix deprecation errors.
2 parents cc62c59 + 6f65337 commit 612cef1

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function export()
261261
];
262262
$_serialize = 'data';
263263

264-
$this->setResponse($this->getResponse()->withDownload('my-file.csv'));
264+
$this->response = $this->response->withDownload('my-file.csv'));
265265
$this->viewBuilder()->setClassName('CsvView.Csv');
266266
$this->set(compact('data', '_serialize'));
267267
}

phpunit.xml.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
syntaxCheck="false"
77
bootstrap="tests/bootstrap.php"
88
>
9-
<php>
10-
<!-- E_ALL => 32767 -->
11-
<!-- E_ALL & ~E_USER_DEPRECATED => 16383 -->
12-
<ini name="error_reporting" value="16383"/>
13-
</php>
149

1510
<!-- Add any additional test suites you want to run here -->
1611
<testsuites>

src/View/CsvView.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,16 @@ protected function getBom($csvEncoding)
484484

485485
return isset($this->bomMap[$csvEncoding]) ? $this->bomMap[$csvEncoding] : '';
486486
}
487+
488+
/**
489+
* Gets the response instance.
490+
*
491+
* Added for compatibility with CakePHP 3.7+.
492+
*
493+
* @return \Cake\Http\Response
494+
*/
495+
public function getResponse()
496+
{
497+
return $this->response;
498+
}
487499
}

tests/TestCase/View/CsvViewTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testRenderWithoutView()
3838
$output = $this->view->render(false);
3939

4040
$this->assertSame('user,fake,list,item1,item2' . PHP_EOL, $output);
41-
$this->assertSame('text/csv', $this->view->response->getType());
41+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
4242
}
4343

4444
/**
@@ -132,7 +132,7 @@ public function testRenderWithoutViewMultiple()
132132

133133
$expected = 'a,b,c' . PHP_EOL . '1,2,3' . PHP_EOL . 'you,and,me' . PHP_EOL;
134134
$this->assertSame($expected, $output);
135-
$this->assertSame('text/csv', $this->view->response->getType());
135+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
136136

137137
$this->view->set('_serialize', true);
138138
$output = $this->view->render(false);
@@ -157,7 +157,7 @@ public function testRenderWithCustomEol()
157157
$output = $this->view->render(false);
158158

159159
$this->assertSame('a,b,c~1,2,3~you,and,me~', $output);
160-
$this->assertSame('text/csv', $this->view->response->getType());
160+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
161161
}
162162

163163
/**
@@ -181,7 +181,7 @@ public function testRenderWithCustomEncoding()
181181
$expected = iconv('UTF-8', 'SJIS', 'a,b,c' . PHP_EOL . '1,2,3' . PHP_EOL . 'あなた,と,私' . PHP_EOL);
182182

183183
$this->assertSame($expected, $output);
184-
$this->assertSame('text/csv', $this->view->response->getType());
184+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
185185
}
186186

187187
/**
@@ -211,7 +211,7 @@ public function testRenderWithMbstring()
211211
$expected = mb_convert_encoding('a,b,c' . PHP_EOL . '1,2,3' . PHP_EOL . 'あなた,と,私' . PHP_EOL, 'SJIS', 'UTF-8');
212212

213213
$this->assertSame($expected, $output);
214-
$this->assertSame('text/csv', $this->view->response->getType());
214+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
215215
}
216216

217217
/**
@@ -233,7 +233,7 @@ public function testRenderWithView()
233233
$output = $this->view->render('index');
234234

235235
$this->assertSame('TEST OUTPUT' . PHP_EOL, $output);
236-
$this->assertSame('text/csv', $this->view->response->getType());
236+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
237237
}
238238

239239
/**
@@ -271,7 +271,7 @@ public function testRenderViaExtract()
271271
$output = $this->view->render(false);
272272

273273
$this->assertSame('jose,"2010-01-05 00:00:00",beach' . PHP_EOL . 'drew,,ball' . PHP_EOL, $output);
274-
$this->assertSame('text/csv', $this->view->response->getType());
274+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
275275
}
276276

277277
/**
@@ -310,7 +310,7 @@ public function testRenderViaExtractOptionalField()
310310
$output = $this->view->render(false);
311311

312312
$this->assertSame('1,jose,,beach' . PHP_EOL . '2,drew,ball,fun' . PHP_EOL, $output);
313-
$this->assertSame('text/csv', $this->view->response->getType());
313+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
314314
}
315315

316316
/**
@@ -350,7 +350,7 @@ function ($row) {
350350
$output = $this->view->render(false);
351351

352352
$this->assertSame('jose,"2010-01-05 00:00:00",my-beach' . PHP_EOL . 'drew,,my-ball' . PHP_EOL, $output);
353-
$this->assertSame('text/csv', $this->view->response->getType());
353+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
354354
}
355355

356356
/**
@@ -403,7 +403,7 @@ public function testRenderWithSpecialCharacters()
403403
404404
CSV;
405405
$this->assertTextEquals($expected, $output);
406-
$this->assertSame('text/csv', $this->view->response->getType());
406+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
407407
}
408408

409409
/**
@@ -452,7 +452,7 @@ public function testRenderEnclosure()
452452
$output = $this->view->render(false);
453453

454454
$this->assertSame($expected, $output);
455-
$this->assertSame('text/csv', $this->view->response->getType());
455+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
456456
}
457457
}
458458

@@ -475,7 +475,7 @@ public function testRenderWithCustomNull()
475475
$output = $this->view->render(false);
476476

477477
$this->assertSame('a,b,c~1,2,NULL~you,NULL,me~', $output);
478-
$this->assertSame('text/csv', $this->view->response->getType());
478+
$this->assertSame('text/csv', $this->view->getResponse()->getType());
479479
}
480480

481481
/**

tests/bootstrap.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
use Cake\Core\Configure;
3-
use Cake\Core\Plugin;
43

54
/**
65
* Test suite bootstrap
@@ -34,4 +33,3 @@
3433
'templates' => [dirname(__FILE__) . DS . 'test_app' . DS . 'TestApp' . DS . 'Template' . DS],
3534
]
3635
]);
37-
Plugin::load('CsvView', ['path' => dirname(dirname(__FILE__)) . DS]);

0 commit comments

Comments
 (0)