BagOStuff $cacheBag,
$insertCalls,
$selectCalls,
- $normalizationCallback = null
+ $normalizationCallback = null,
+ $insertCallback = null
) {
return new NameTableStore(
$this->getMockLoadBalancer( $this->getCallCheckingDb( $insertCalls, $selectCalls ) ),
$this->getHashWANObjectCache( $cacheBag ),
new NullLogger(),
'slot_roles', 'role_id', 'role_name',
- $normalizationCallback
+ $normalizationCallback,
+ false,
+ $insertCallback
);
}
$store->getMap();
$table = $store->getMap();
- $expected = [ 2 => 'bar', 1 => 'foo' ];
+ $expected = [ 1 => 'foo', 2 => 'bar' ];
$this->assertSame( $expected, $table );
// Make sure the table returned is the same as the cached table
$this->assertSame( $expected, TestingAccessWrapper::newFromObject( $store )->tableCache );
$this->assertSame( $barId, $store3->acquireId( 'bar' ) );
}
+ public function testGetAndAcquireIdInsertCallback() {
+ $store = $this->getNameTableSqlStore(
+ new EmptyBagOStuff(),
+ 1,
+ 1,
+ null,
+ function ( $insertFields ) {
+ $insertFields['role_id'] = 7251;
+ return $insertFields;
+ }
+ );
+ $this->assertSame( 7251, $store->acquireId( 'A' ) );
+ }
+
}