BatchWriterTest.php 897 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Ddeboer\DataImport\Tests\Writer;
  3. use Ddeboer\DataImport\Writer\BatchWriter;
  4. class BatchWriterTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testWriteItem()
  7. {
  8. $delegate = $this->getMock('Ddeboer\DataImport\Writer');
  9. $writer = new BatchWriter($delegate);
  10. $delegate->expects($this->once())
  11. ->method('prepare');
  12. $delegate->expects($this->never())
  13. ->method('writeItem');
  14. $writer->prepare();
  15. $writer->writeItem(['Test']);
  16. }
  17. public function testFlush()
  18. {
  19. $delegate = $this->getMock('Ddeboer\DataImport\Writer');
  20. $writer = new BatchWriter($delegate);
  21. $delegate->expects($this->exactly(20))
  22. ->method('writeItem');
  23. $writer->prepare();
  24. for ($i = 0; $i < 20; $i++) {
  25. $writer->writeItem(['Test']);
  26. }
  27. }
  28. }