diff --git a/README.md b/README.md
index 0adc8a1..6c5d3fa 100644
--- a/README.md
+++ b/README.md
@@ -261,7 +261,7 @@ public function export()
];
$_serialize = 'data';
- $this->setResponse($this->getResponse()->withDownload('my-file.csv'));
+ $this->response = $this->response->withDownload('my-file.csv'));
$this->viewBuilder()->setClassName('CsvView.Csv');
$this->set(compact('data', '_serialize'));
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 0e48239..0377579 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -6,11 +6,6 @@
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
-
-
-
-
-
diff --git a/src/View/CsvView.php b/src/View/CsvView.php
index 032b559..55c57a3 100644
--- a/src/View/CsvView.php
+++ b/src/View/CsvView.php
@@ -484,4 +484,16 @@ protected function getBom($csvEncoding)
return isset($this->bomMap[$csvEncoding]) ? $this->bomMap[$csvEncoding] : '';
}
+
+ /**
+ * Gets the response instance.
+ *
+ * Added for compatibility with CakePHP 3.7+.
+ *
+ * @return \Cake\Http\Response
+ */
+ public function getResponse()
+ {
+ return $this->response;
+ }
}
diff --git a/tests/TestCase/View/CsvViewTest.php b/tests/TestCase/View/CsvViewTest.php
index 3764cca..efa0be9 100644
--- a/tests/TestCase/View/CsvViewTest.php
+++ b/tests/TestCase/View/CsvViewTest.php
@@ -38,7 +38,7 @@ public function testRenderWithoutView()
$output = $this->view->render(false);
$this->assertSame('user,fake,list,item1,item2' . PHP_EOL, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -132,7 +132,7 @@ public function testRenderWithoutViewMultiple()
$expected = 'a,b,c' . PHP_EOL . '1,2,3' . PHP_EOL . 'you,and,me' . PHP_EOL;
$this->assertSame($expected, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
$this->view->set('_serialize', true);
$output = $this->view->render(false);
@@ -157,7 +157,7 @@ public function testRenderWithCustomEol()
$output = $this->view->render(false);
$this->assertSame('a,b,c~1,2,3~you,and,me~', $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -181,7 +181,7 @@ public function testRenderWithCustomEncoding()
$expected = iconv('UTF-8', 'SJIS', 'a,b,c' . PHP_EOL . '1,2,3' . PHP_EOL . 'あなた,と,私' . PHP_EOL);
$this->assertSame($expected, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -211,7 +211,7 @@ public function testRenderWithMbstring()
$expected = mb_convert_encoding('a,b,c' . PHP_EOL . '1,2,3' . PHP_EOL . 'あなた,と,私' . PHP_EOL, 'SJIS', 'UTF-8');
$this->assertSame($expected, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -233,7 +233,7 @@ public function testRenderWithView()
$output = $this->view->render('index');
$this->assertSame('TEST OUTPUT' . PHP_EOL, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -271,7 +271,7 @@ public function testRenderViaExtract()
$output = $this->view->render(false);
$this->assertSame('jose,"2010-01-05 00:00:00",beach' . PHP_EOL . 'drew,,ball' . PHP_EOL, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -310,7 +310,7 @@ public function testRenderViaExtractOptionalField()
$output = $this->view->render(false);
$this->assertSame('1,jose,,beach' . PHP_EOL . '2,drew,ball,fun' . PHP_EOL, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -350,7 +350,7 @@ function ($row) {
$output = $this->view->render(false);
$this->assertSame('jose,"2010-01-05 00:00:00",my-beach' . PHP_EOL . 'drew,,my-ball' . PHP_EOL, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -403,7 +403,7 @@ public function testRenderWithSpecialCharacters()
CSV;
$this->assertTextEquals($expected, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
@@ -452,7 +452,7 @@ public function testRenderEnclosure()
$output = $this->view->render(false);
$this->assertSame($expected, $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
}
@@ -475,7 +475,7 @@ public function testRenderWithCustomNull()
$output = $this->view->render(false);
$this->assertSame('a,b,c~1,2,NULL~you,NULL,me~', $output);
- $this->assertSame('text/csv', $this->view->response->getType());
+ $this->assertSame('text/csv', $this->view->getResponse()->getType());
}
/**
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 70a5aa4..e2b3873 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,6 +1,5 @@
[dirname(__FILE__) . DS . 'test_app' . DS . 'TestApp' . DS . 'Template' . DS],
]
]);
-Plugin::load('CsvView', ['path' => dirname(dirname(__FILE__)) . DS]);