Skip to content

Commit

Permalink
Merge pull request #99 from FriendsOfCake/deprecations
Browse files Browse the repository at this point in the history
Fix usage of deprecated method.
  • Loading branch information
ADmad authored Aug 15, 2018
2 parents 6d2d29f + fa588f8 commit 81f2f05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<!-- E_ALL & ~E_USER_DEPRECATED (16383)-->
<!-- E_ALL (32767) -->
<ini name="error_reporting" value="16383"/>
</php>

<!-- Add any additional test suites you want to run here -->
Expand Down
4 changes: 1 addition & 3 deletions src/View/CsvView.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ public function __construct(

parent::__construct($request, $response, $eventManager, $viewOptions);

if ($response && $response instanceof Response) {
$response->type('csv');
}
$this->response = $this->response->withType('csv');
}

/**
Expand Down
24 changes: 12 additions & 12 deletions tests/TestCase/View/CsvViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down Expand Up @@ -80,7 +80,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());

$this->view->set('_serialize', true);
$output = $this->view->render(false);
Expand All @@ -105,7 +105,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand All @@ -129,7 +129,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down Expand Up @@ -159,7 +159,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand All @@ -181,7 +181,7 @@ public function testRenderWithView()
$output = $this->view->render('index');

$this->assertSame('TEST OUTPUT' . PHP_EOL, $output);
$this->assertSame('text/csv', $this->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down Expand Up @@ -219,7 +219,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down Expand Up @@ -258,7 +258,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down Expand Up @@ -298,7 +298,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down Expand Up @@ -351,7 +351,7 @@ public function testRenderWithSpecialCharacters()
CSV;
$this->assertTextEquals($expected, $output);
$this->assertSame('text/csv', $this->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down Expand Up @@ -400,7 +400,7 @@ public function testRenderEnclosure()
$output = $this->view->render(false);

$this->assertSame($expected, $output);
$this->assertSame('text/csv', $this->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}
}

Expand All @@ -423,7 +423,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->response->getType());
$this->assertSame('text/csv', $this->view->response->getType());
}

/**
Expand Down

0 comments on commit 81f2f05

Please sign in to comment.