public function testWriterBasicFunctionality()
 {
     $db = $this->mockDb();
     $writer = new BatchRowWriter($db, 'echo_event');
     $updates = array(self::mockUpdate(array('something' => 'changed')), self::mockUpdate(array('otherthing' => 'changed')), self::mockUpdate(array('and' => 'something', 'else' => 'changed')));
     $db->expects($this->exactly(count($updates)))->method('update');
     $writer->write($updates);
 }
 /**
  * Runs the batch update process
  */
 public function execute()
 {
     foreach ($this->reader as $rows) {
         $updates = [];
         foreach ($rows as $row) {
             $update = $this->generator->update($row);
             if ($update) {
                 $updates[] = ['primaryKey' => $this->reader->extractPrimaryKeys($row), 'changes' => $update];
             }
         }
         if ($updates) {
             $this->output("Processing " . count($updates) . " rows\n");
             $this->writer->write($updates);
         }
     }
     $this->output("Completed\n");
 }