/** * @covers ::getBulkInserter * @dataProvider dbProvider * @param YoPdo $yo_pdo */ public function testBulkInserterRetrievedFromYoPdoCanBeUsed(YoPdo $yo_pdo) { $table_name = $this->sample_table_creator->createTable($yo_pdo); $bulk_inserter = $yo_pdo->getBulkInserter($table_name, ['a', 'b'], 3); $bulk_inserter->insertRecords([[4, 5], [102, 32], [43, 12]]); $this->result_asserter->assertResults($yo_pdo, $table_name, array(1 => array('a' => 4, 'b' => 5), 2 => array('a' => 102, 'b' => 32), 3 => array('a' => 43, 'b' => 12))); }
/** * @covers ::begin * @covers ::rollbackAll * @dataProvider dbProvider * @param YoPdo $yo_pdo */ public function testRollbackAllEndsAllNames(YoPdo $yo_pdo) { $rows = $this->sample_table_creator->getSampleRows(); $table_name = $this->sample_table_creator->createTable($yo_pdo); $yo_pdo->transaction()->begin('outer'); $yo_pdo->transaction()->begin('inner'); $yo_pdo->insert($table_name, $rows[1]); $yo_pdo->transaction()->rollbackAll(); $this->assertUnknownTransactionNameException($yo_pdo, 'inner'); $this->assertUnknownTransactionNameException($yo_pdo, 'outer'); }
/** * @covers ::bufferRecord * @dataProvider dbProvider * @param YoPdo $yo_pdo */ public function testManyPreparedPlaceholdersCanBeUsed(YoPdo $yo_pdo) { $table_name = $this->sample_table_creator->createTable($yo_pdo); $bulk_inserter = new BulkInserter($yo_pdo, $table_name, ['a', 'b'], 2500); $expected_records = []; for ($i = 0; $i < 5000; $i++) { $record = ['a' => $i, 'b' => 500000 - $i]; $bulk_inserter->bufferRecord([$record['a'], $record['b']]); $expected_records[$i + 1] = $record; } $this->result_asserter->assertResults($yo_pdo, $table_name, $expected_records); }