ConsoleTableWriterTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Ddeboer\DataImport\Tests\Writer;
  3. use Symfony\Component\Console\Output\BufferedOutput;
  4. use Symfony\Component\Console\Helper\Table;
  5. use Ddeboer\DataImport\Workflow\StepAggregator;
  6. use Ddeboer\DataImport\Reader\ArrayReader;
  7. use Ddeboer\DataImport\ItemConverter\MappingItemConverter;
  8. use Ddeboer\DataImport\Writer\ConsoleTableWriter;
  9. /**
  10. * @author Igor Mukhin <igor.mukhin@gmail.com>
  11. */
  12. class ConsoleTableWriterTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testRightColumnsHeadersNamesAfterItemConverter()
  15. {
  16. $data = array(
  17. array(
  18. 'firstname' => 'John',
  19. 'lastname' => 'Doe'
  20. ),
  21. array(
  22. 'firstname' => 'Ivan',
  23. 'lastname' => 'Sidorov'
  24. )
  25. );
  26. $reader = new ArrayReader($data);
  27. $output = new BufferedOutput();
  28. $table = $this->getMockBuilder('Symfony\Component\Console\Helper\Table')
  29. ->disableOriginalConstructor()
  30. ->getMock();
  31. $table->expects($this->at(2))
  32. ->method('addRow');
  33. $workflow = new StepAggregator($reader);
  34. $workflow
  35. ->addWriter(new ConsoleTableWriter($output, $table))
  36. ->process()
  37. ;
  38. }
  39. }