コード例 #1
0
ファイル: BatchWriterTest.php プロジェクト: repat/data-import
 public function testFlush()
 {
     $delegate = $this->getMock('Ddeboer\\DataImport\\Writer');
     $writer = new BatchWriter($delegate);
     $delegate->expects($this->exactly(20))->method('writeItem');
     $writer->prepare();
     for ($i = 0; $i < 20; $i++) {
         $writer->writeItem(['Test']);
     }
 }
コード例 #2
0
 public function testFlushWithFlushableDelegate()
 {
     $prophet = new \Prophecy\Prophet();
     $prophecy = $prophet->prophesize();
     $prophecy->willExtend('stdClass');
     $prophecy->willImplement('Ddeboer\\DataImport\\Writer');
     $prophecy->willImplement('Ddeboer\\DataImport\\Writer\\FlushableWriter');
     $prophecy->writeItem(\Prophecy\Argument::any())->shouldBeCalledTimes(40);
     $prophecy->prepare()->shouldBeCalledTimes(2);
     $prophecy->flush()->shouldBeCalled();
     $writer = new BatchWriter($prophecy->reveal());
     $writer->prepare();
     for ($i = 0; $i < 40; $i++) {
         $writer->writeItem(['Test']);
     }
 }