icingaweb2/test/php/library/Icinga/File/CsvTest.php
jrauh01 3b9d663bcf
Replace array() with [] (#5509)
Replace the outdated `array()` spelling with the more modern `[]`. This
is applied throughout the whole project, also including phpdocs, tests,
view scripts and core modules.
2026-07-01 14:19:02 +02:00

36 lines
1,001 B
PHP

<?php
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Tests\Icinga\File;
use Icinga\Data\DataArray\ArrayDatasource;
use Icinga\File\Csv;
use Icinga\Test\BaseTestCase;
class CsvTest extends BaseTestCase
{
public function testWhetherValidCsvIsRendered()
{
$data = new ArrayDatasource([
['col1' => 'val1', 'col2' => 'val2', 'col3' => 'val3', 'col4' => 'val4'],
['col1' => 'val5', 'col2' => 'val6', 'col3' => 'val7', 'col4' => 'val8']
]);
$csv = Csv::fromQuery($data->select());
$this->assertEquals(
implode(
"\r\n",
[
'col1,col2,col3,col4',
'"val1","val2","val3","val4"',
'"val5","val6","val7","val8"'
]
) . "\r\n",
(string) $csv,
'Csv does not render valid/correct csv structured data'
);
}
}