IteratorReaderTest.php 756 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Ddeboer\DataImport\Tests\Reader;
  3. use Ddeboer\DataImport\Reader\IteratorReader;
  4. /**
  5. * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
  6. */
  7. class IteratorReaderTest extends \PHPUnit_Framework_TestCase
  8. {
  9. public function testGetFields()
  10. {
  11. $iterator = new \ArrayIterator([
  12. [
  13. 'id' => 1,
  14. 'username' => 'john.doe',
  15. 'name' => 'John Doe',
  16. ],
  17. ]);
  18. $reader = new IteratorReader($iterator);
  19. // We need to rewind the iterator
  20. $reader->rewind();
  21. $fields = $reader->getFields();
  22. $this->assertInternalType('array', $fields);
  23. $this->assertEquals(['id', 'username', 'name'], $fields);
  24. }
  25. }