addDefinitions(__DIR__ . '/../test-dependencies.php'); $container = $builder->build(); $application = new Application('Command Line Tool to process Youtrack Reports', '0.1.0'); $invoiceCommand = $container->get(InvoiceCommand::class); $application->add($invoiceCommand); $reportCommand = $container->get(ReportCommand::class); $application->add($reportCommand); $reportCommand = $application->find('report'); $reportCommandTester = new CommandTester($reportCommand); $reportCommandTester->execute([ // pass arguments to the helper '--file' => __DIR__ . '/../data/21-03.csv', // prefix the key with two dashes when passing options, // e.g: '--some-option' => 'option_value', // use brackets for testing array value, // e.g: '--some-option' => ['option_value'], ]); $reportCommandTester->assertCommandIsSuccessful(); // the output of the command in the console $output = $reportCommandTester->getDisplay(); // var_dump($output); $this->assertStringContainsString('21-03.csv', $output); $this->assertStringEqualsFile(self::REPORT_OUTPUT_FILE, $output); $invoiceCommand = $application->find('invoice'); $invoiceCommandTester = new CommandTester($invoiceCommand); $invoiceCommandTester->execute([ '--file' => self::INPUT_CSV_FILE, '--pdf' => TRUE, ]); $invoiceCommandTester->assertCommandIsSuccessful(); // the output of the command in the console $invoice_output = $invoiceCommandTester->getDisplay(); var_dump($invoice_output); $this->assertStringContainsString('21-03.csv', $invoice_output); $this->assertStringEqualsFile(self::INVOICE_OUTPUT_FILE, $invoice_output); // $invoiceCommandTester->execute([ // '--file' => self::INPUT_CSV_FILE, // '--pdf' // ]); // $invoice_output = $invoiceCommandTester->getDisplay(); // var_dump($invoice_output); // $this->assertFileExists(); } }