function testSimpleList() { $expected = <<<EOT ------- -------- One apple Two banana Three carrot ------- -------- EOT; $data = $this->simpleListExampleDataUsingAssociativeList(); $this->assertFormattedOutputMatches($expected, 'table', $data); $data = $this->simpleListExampleData(); $this->assertFormattedOutputMatches($expected, 'table', $data); $expected = <<<EOT ----- -------- I apple II banana III carrot ----- -------- EOT; // If we provide field labels, then the output will change to reflect that. $formatterOptionsWithFieldLables = new FormatterOptions(); $formatterOptionsWithFieldLables->setFieldLabels(['one' => 'I', 'two' => 'II', 'three' => 'III']); $this->assertFormattedOutputMatches($expected, 'table', $data, $formatterOptionsWithFieldLables); $expectedDrushStyleTable = <<<EOT One : apple Two : banana Three : carrot EOT; // If we provide field labels, then the output will change to reflect that. $formatterOptionsWithFieldLables = new FormatterOptions(); $formatterOptionsWithFieldLables->setTableStyle('compact')->setListDelimiter(':'); $this->assertFormattedOutputMatches($expectedDrushStyleTable, 'table', $data, $formatterOptionsWithFieldLables); // Adding an extra field that does not exist in the data set should not change the output $formatterOptionsWithExtraFieldLables = new FormatterOptions(); $formatterOptionsWithExtraFieldLables->setFieldLabels(['one' => 'I', 'two' => 'II', 'three' => 'III', 'four' => 'IV']); $this->assertFormattedOutputMatches($expected, 'table', $data, $formatterOptionsWithExtraFieldLables); $expectedRotated = <<<EOT ------- -------- -------- One Two Three ------- -------- -------- apple banana carrot ------- -------- -------- EOT; $this->assertFormattedOutputMatches($expectedRotated, 'table', $data, new FormatterOptions(['list-orientation' => false])); $expectedList = <<<EOT apple banana carrot EOT; $this->assertFormattedOutputMatches($expectedList, 'list', $data); $expectedReorderedList = <<<EOT carrot apple EOT; $options = new FormatterOptions([FormatterOptions::FIELDS => 'three,one']); $this->assertFormattedOutputMatches($expectedReorderedList, 'list', $data, $options); $expectedCsv = <<<EOT One,Two,Three apple,banana,carrot EOT; $this->assertFormattedOutputMatches($expectedCsv, 'csv', $data); $expectedCsvNoHeaders = 'apple,banana,carrot'; $this->assertFormattedOutputMatches($expectedCsvNoHeaders, 'csv', $data, new FormatterOptions(), ['include-field-labels' => false]); // Next, configure the formatter options with 'include-field-labels', // but set --include-field-labels to turn the option back on again. $options = new FormatterOptions(['include-field-labels' => false]); $input = new StringInput('test --include-field-labels'); $optionDefinitions = [new InputArgument('unused', InputArgument::REQUIRED), new InputOption('include-field-labels', null, InputOption::VALUE_NONE)]; $definition = new InputDefinition($optionDefinitions); $input->bind($definition); $testValue = $input->getOption('include-field-labels'); $this->assertTrue($testValue); $hasFieldLabels = $input->hasOption('include-field-labels'); $this->assertTrue($hasFieldLabels); $this->assertFormattedOutputMatches($expectedCsvNoHeaders, 'csv', $data, $options); $options->setInput($input); $this->assertFormattedOutputMatches($expectedCsv, 'csv', $data, $options); }