/** * Runs the batch update process */ public function execute() { foreach ($this->reader as $rows) { $updates = array(); foreach ($rows as $row) { $update = $this->generator->update($row); if ($update) { $updates[] = array('primaryKey' => $this->reader->extractPrimaryKeys($row), 'changes' => $update); } } if ($updates) { $this->output("Processing " . count($updates) . " rows\n"); $this->writer->write($updates); } } $this->output("Completed\n"); }
/** * @dataProvider provider_readerGetPrimaryKey */ public function testReaderGetPrimaryKey($message, array $expected, array $row) { $reader = new EchoBatchRowIterator($this->mockDb(), 'some_table', array_keys($expected), 8675309); $this->assertEquals($expected, $reader->extractPrimaryKeys((object) $row), $message); }