mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Added test for the case of objects as cells
I encountered this in Drupal 8, where cells implemented the
MarkupInterface. It was objects that, when cast to a string,
returned the translated string.
Before 5ca540daa7, this new test
would fail.
This commit is contained in:
@@ -88,6 +88,18 @@ class UnparseTest extends Testcase {
|
||||
$this->unparseAndCompare($expected);
|
||||
}
|
||||
|
||||
public function testObjectCells() {
|
||||
$this->csv->data = [
|
||||
[
|
||||
'column1' => new ObjectThatHasToStringMethod(),
|
||||
'column2' => 'boring',
|
||||
],
|
||||
];
|
||||
$this->csv->linefeed = "\n";
|
||||
$expected = "column1,column2\nsome value,boring\n";
|
||||
$this->unparseAndCompare($expected);
|
||||
}
|
||||
|
||||
private function unparseAndCompare($expected, $fields = array()) {
|
||||
$str = $this->csv->unparse($this->csv->data, $fields);
|
||||
$this->assertEquals($expected, $str);
|
||||
|
||||
Reference in New Issue
Block a user