/** * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null|int null or 0 if everything went fine, or an error code */ private function executeSingle(InputInterface $input, OutputInterface $output) { $counts = []; if ($input->getOption('separate')) { foreach ($input->getArgument('values') as $directory) { $count = $this->count([$directory], $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'), $input->getOption('count-tests')); $count['project_directory'] = $directory; $counts[] = $count; } } else { $counts[] = $this->count($input->getArgument('values'), $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'), $input->getOption('count-tests')); } if (!$counts || count($counts) < 1) { $output->writeln('No files found to scan'); exit(1); } $printer = new Text(); foreach ($counts as $count) { $printer->printResult($output, $count, $input->getOption('count-tests')); } if ($input->getOption('log-csv')) { $printer = new Single(); foreach ($counts as $count) { $printer->addResult($input->getOption('log-csv'), $count); } } if ($input->getOption('log-xml')) { $printer = new XML(); foreach ($counts as $count) { $printer->addResult($input->getOption('log-xml'), $count); } } }
public function testExactlyThreeRowsArePrinted() { ob_start(); $this->history->printResult('php://output', $this->sample_data); $output = ob_get_clean(); $rows = explode("\n", trim($output)); $this->assertEquals(3, count($rows), "Printed result contained more or less than expected 2 rows"); }
/** * @expectedException \InvalidArgumentException */ public function testPrintPartialRow() { $count = $this->sample_row; unset($count['llocByNof']); ob_start(); $this->single->printResult('php://output', $count); ob_end_clean(); $this->fail("No exception was raised for malformed input var"); }
public function testExactlyThreeRowsArePrinted() { ob_start(); foreach ($this->sample_data as $row) { $this->history->printRow($row); } $output = ob_get_clean(); $rows = explode("\n", trim($output)); $this->assertEquals(3, count($rows), 'Printed result contained more or less than expected 2 rows'); }
public function testProjectSeparation() { $sample1 = array_merge(['project_directory' => rand()], $this->sample_row); $sample2 = array_merge(['project_directory' => rand()], $this->sample_row); // Clean previous CSV file. $this->setUp(); ob_start(); $this->single->addResult('php://output', $sample1); $this->single->addResult('php://output', $sample2); $output = ob_get_clean(); $this->assertRegExp('#Project Directory,Directories,Files.+$#is', $output, "Printed result does not contain project directory header"); $rows = explode("\n", trim($output)); $this->assertEquals(3, count($rows), "Printed result contained more or less than expected 3 rows (1 header and 2 project lines)"); }
/** * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null|integer null or 0 if everything went fine, or an error code */ private function executeSingle(InputInterface $input, OutputInterface $output) { $count = $this->count($input->getArgument('values'), $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'), $input->getOption('count-tests')); if (!$count) { $output->writeln('No files found to scan'); exit(1); } $printer = new Text(); $printer->printResult($output, $count, $input->getOption('count-tests')); if ($input->getOption('log-csv')) { $printer = new Single(); $printer->printResult($input->getOption('log-csv'), $count); } if ($input->getOption('log-xml')) { $printer = new XML(); $printer->printResult($input->getOption('log-xml'), $count); } }