ConsoleProgressWriterTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Ddeboer\DataImport\Tests\Writer;
  3. use Ddeboer\DataImport\Writer\ConsoleProgressWriter;
  4. use Ddeboer\DataImport\Workflow\StepAggregator;
  5. use Ddeboer\DataImport\Reader\ArrayReader;
  6. use Symfony\Component\Console\Output\NullOutput;
  7. class ConsoleProgressWriterTest extends \PHPUnit_Framework_TestCase
  8. {
  9. public function testWrite()
  10. {
  11. $data = array(
  12. array(
  13. 'first' => 'The first',
  14. 'second' => 'Second property'
  15. ), array(
  16. 'first' => 'Another first',
  17. 'second' => 'Last second'
  18. )
  19. );
  20. $reader = new ArrayReader($data);
  21. $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')
  22. ->getMock();
  23. $outputFormatter = $this->getMock('Symfony\Component\Console\Formatter\OutputFormatterInterface');
  24. $output->expects($this->once())
  25. ->method('isDecorated')
  26. ->will($this->returnValue(true));
  27. $output->expects($this->atLeastOnce())
  28. ->method('getFormatter')
  29. ->will($this->returnValue($outputFormatter));
  30. $output->expects($this->atLeastOnce())
  31. ->method('write');
  32. $writer = new ConsoleProgressWriter($output, $reader);
  33. $workflow = new StepAggregator($reader);
  34. $workflow->addWriter($writer)
  35. ->process();
  36. $this->assertEquals('debug', $writer->getVerbosity());
  37. }
  38. }