Skip to content

Commit

Permalink
Fix xml converter test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 27, 2025
1 parent 26912a2 commit 547f2a4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/AbstractCsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use function ob_get_clean;
use function ob_start;
use function strtolower;
use function Symfony\Component\VarDumper\Dumper\esc;
use function tempnam;
use function tmpfile;
use function unlink;
Expand All @@ -47,7 +46,7 @@ protected function setUp(): void
{
$tmp = new SplTempFileObject();
foreach ($this->expected as $row) {
$tmp->fputcsv($row, escape: "\\");
$tmp->fputcsv($row, escape: '\\');
}

$this->csv = Reader::createFromFileObject($tmp);
Expand Down
2 changes: 1 addition & 1 deletion src/CallbackStreamFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function it_can_be_added_to_a_stream(): void
StreamFilter::appendOnReadTo($stream, 'swap.carrier.return');
StreamFilter::prependOnReadTo($stream, 'toUpper');
$data = [];
while (($record = fgetcsv($stream, 1000, ',', escape: "\\")) !== false) {
while (($record = fgetcsv($stream, 1000, ',', escape: '\\')) !== false) {
$data[] = $record;
}
fclose($stream);
Expand Down
1 change: 1 addition & 0 deletions src/XMLConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function convert(iterable $records): DOMDocument|XMLDocument
*/
public function download(iterable $records, ?string $filename = null, string $encoding = 'utf-8', bool $formatOutput = false): int|false
{
/** @var XMLDocument|DOMDocument $document */
$document = $this->convert($records);

if (null !== $filename) {
Expand Down
6 changes: 3 additions & 3 deletions src/XMLConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ public function testDownload(): void

ob_start();
XMLConverter::create()->fieldElement('cell', 'name')->download([['foo' => 'bar']], 'foobar.xml');
$output = ob_get_clean();
$output = (string) ob_get_clean();
$headers = xdebug_get_headers();

$xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n".'<csv><row><cell name="foo">bar</cell></row></csv>'."\n";
$xml = '<csv><row><cell name="foo">bar</cell></row></csv>';

self::assertStringContainsString('content-type: application/xml', strtolower($headers[0]));
self::assertSame('content-transfer-encoding: binary', strtolower($headers[1]));
self::assertSame('content-description: File Transfer', $headers[2]);
self::assertStringContainsString('content-disposition: attachment;filename="foobar.xml"', $headers[3]);
self::assertSame($xml, $output);
self::assertStringContainsString($xml, $output);
}

public function testToXMLWithFormatter(): void
Expand Down

0 comments on commit 547f2a4

Please sign in to comment.