CallbackWriterTest.php 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Ddeboer\DataImport\Tests\Writer;
  3. use Ddeboer\DataImport\Writer\CallbackWriter;
  4. /**
  5. * @author Markus Bachmann <markus.bachmann@bachi.biz>
  6. */
  7. class CallbackWriterTest extends \PHPUnit_Framework_TestCase
  8. {
  9. public function testPrepare()
  10. {
  11. $callable = function(array $item) {
  12. return '';
  13. };
  14. $writer = new CallbackWriter($callable);
  15. $writer->prepare();
  16. }
  17. public function testWriteItem()
  18. {
  19. $string = '';
  20. $callable = function(array $item) use (&$string) {
  21. $string = implode(',', array_values($item));
  22. };
  23. $writer = new CallbackWriter($callable);
  24. $writer->writeItem(array('foo' => 'bar', 'bar' => 'foo'));
  25. $this->assertEquals('bar,foo', $string);
  26. }
  27. public function testFinish()
  28. {
  29. $callable = function(array $item) {
  30. return '';
  31. };
  32. $writer = new CallbackWriter($callable);
  33. $writer->finish();
  34. }
  35. }