From bc9207de099de809dc4d4dbaac1ccfa830eb48d4 Mon Sep 17 00:00:00 2001 From: Fonata Date: Sat, 2 Feb 2019 18:39:21 +0100 Subject: [PATCH 1/2] Added example for writing CSV files to better document heading property Fixes #161 --- examples/save_to_file_without_header_row.php | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/save_to_file_without_header_row.php diff --git a/examples/save_to_file_without_header_row.php b/examples/save_to_file_without_header_row.php new file mode 100644 index 0000000..0b2ff44 --- /dev/null +++ b/examples/save_to_file_without_header_row.php @@ -0,0 +1,27 @@ +heading = false; + +# Specify which columns to write, and in which order. +# We won't output the 'Awesome' column this time. +$csv->titles = ['Age', 'Name']; + +# Data to write: +$csv->data = [ + 0 => ['Name' => 'Anne', 'Age' => 45, 'Awesome' => true], + 1 => ['Name' => 'John', 'Age' => 44, 'Awesome' => false], +]; + +# Then we save the file to the file system: +$csv->save('people.csv'); From 2d428ffa932744b9af8c6e8fc66c58025afc8313 Mon Sep 17 00:00:00 2001 From: Fonata Date: Sat, 2 Feb 2019 18:47:55 +0100 Subject: [PATCH 2/2] Updated test: no output in save_to_file_without_header_row.php Thus, effectively, we just test for valid PHP syntax. --- tests/methods/ConstructTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/methods/ConstructTest.php b/tests/methods/ConstructTest.php index 35ddd33..c0a91af 100644 --- a/tests/methods/ConstructTest.php +++ b/tests/methods/ConstructTest.php @@ -59,7 +59,9 @@ class ConstructTest extends TestCase { /** @noinspection PhpIncludeInspection */ require $script_file; $ob_get_clean = ob_get_clean(); - if ($script_file != 'download.php') { + $verb = strtok($script_file, '_.'); + + if (!in_array($verb, ['download', 'save'], true)) { $this->assertContains('', $ob_get_clean); } }