39 'wgBlockDisablesLogin' =>
false,
46 $this->blockRestrictionStore->insert( [
52 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
54 $this->assertCount( 3, $restrictions );
64 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
65 $this->assertEmpty( $restrictions );
74 $restrictions = $this->blockRestrictionStore->loadByBlockId( [] );
75 $this->assertEmpty( $restrictions );
97 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
98 $this->assertCount( 2, $restrictions );
112 $this->blockRestrictionStore->insert( [
116 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
118 list( $pageRestriction ) = $restrictions;
120 $this->assertEquals( $block->getId(), $pageRestriction->getBlockId() );
121 $this->assertEquals( $page->getId(), $pageRestriction->getValue() );
123 $this->assertEquals( $pageRestriction->getTitle()->getText(),
$title );
134 $this->blockRestrictionStore->insert( [
138 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
140 list( $namespaceRestriction ) = $restrictions;
142 $this->assertEquals( $block->getId(), $namespaceRestriction->getBlockId() );
143 $this->assertSame(
NS_USER, $namespaceRestriction->getValue() );
163 $result = $this->blockRestrictionStore->insert( $restrictions );
170 $result = $this->blockRestrictionStore->insert( $restrictions );
173 $result = $this->blockRestrictionStore->insert( [] );
187 $invalid->method(
'toRow' )
189 'ir_ipb_id' => $block->getId(),
202 $result = $this->blockRestrictionStore->insert( $restrictions );
205 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
206 $this->assertCount( 3, $restrictions );
218 $this->blockRestrictionStore->insert( [
222 $this->blockRestrictionStore->update( [
230 [
'ipblocks_restrictions' ],
232 [
'ir_ipb_id' => $block->getId() ]
235 $this->assertEquals( 2,
$result->numRows() );
237 $this->assertEquals( $block->getId(), $row->ir_ipb_id );
238 $this->assertEquals( $pageBar->getId(), $row->ir_value );
250 $this->blockRestrictionStore->update( [
256 [
'ipblocks_restrictions' ],
258 [
'ir_ipb_id' => $block->getId() ]
261 $this->assertEquals( 1,
$result->numRows() );
263 $this->assertEquals( $block->getId(), $row->ir_ipb_id );
264 $this->assertEquals( $page->getId(), $row->ir_value );
275 $this->blockRestrictionStore->update( [] );
279 [
'ipblocks_restrictions' ],
281 [
'ir_ipb_id' => $block->getId() ]
284 $this->assertEquals( 0,
$result->numRows() );
295 $this->blockRestrictionStore->insert( [
299 $this->blockRestrictionStore->update( [
305 [
'ipblocks_restrictions' ],
307 [
'ir_ipb_id' => $block->getId() ]
310 $this->assertEquals( 1,
$result->numRows() );
312 $this->assertEquals( $block->getId(), $row->ir_ipb_id );
313 $this->assertEquals( $page->getId(), $row->ir_value );
324 $this->blockRestrictionStore->insert( [
327 $autoblockId = $block->doAutoblock(
'127.0.0.1' );
330 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
331 $this->assertCount( 1, $restrictions );
332 $this->assertEquals( $pageFoo->getId(), $restrictions[0]->getValue() );
335 $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
336 $this->assertCount( 1, $restrictions );
337 $this->assertEquals( $pageFoo->getId(), $restrictions[0]->getValue() );
340 $this->blockRestrictionStore->updateByParentBlockId( $block->getId(), [
345 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
346 $this->assertCount( 1, $restrictions );
347 $this->assertEquals( $pageFoo->getId(), $restrictions[0]->getValue() );
350 $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
351 $this->assertCount( 1, $restrictions );
352 $this->assertEquals( $pageBar->getId(), $restrictions[0]->getValue() );
362 $this->blockRestrictionStore->insert( [
365 $autoblockId = $block->doAutoblock(
'127.0.0.1' );
368 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
369 $this->assertCount( 1, $restrictions );
372 $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
373 $this->assertCount( 1, $restrictions );
376 $this->blockRestrictionStore->updateByParentBlockId( $block->getId(), [] );
379 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
380 $this->assertCount( 1, $restrictions );
383 $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
384 $this->assertCount( 0, $restrictions );
394 $this->blockRestrictionStore->insert( [
399 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
400 $this->assertCount( 1, $restrictions );
403 $this->blockRestrictionStore->updateByParentBlockId( $block->getId(), $restrictions );
406 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
407 $this->assertCount( 1, $restrictions );
416 $this->blockRestrictionStore->insert( [
420 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
421 $this->assertCount( 1, $restrictions );
423 $result = $this->blockRestrictionStore->delete(
424 array_merge( $restrictions, [
new \stdClass() ] )
428 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
429 $this->assertCount( 0, $restrictions );
438 $this->blockRestrictionStore->insert( [
442 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
443 $this->assertCount( 1, $restrictions );
445 $result = $this->blockRestrictionStore->deleteByBlockId( $block->getId() );
446 $this->assertNotFalse(
$result );
448 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
449 $this->assertCount( 0, $restrictions );
459 $this->blockRestrictionStore->insert( [
462 $autoblockId = $block->doAutoblock(
'127.0.0.1' );
465 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
466 $this->assertCount( 1, $restrictions );
469 $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
470 $this->assertCount( 1, $restrictions );
473 $result = $this->blockRestrictionStore->deleteByParentBlockId( $block->getId() );
478 $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
479 $this->assertCount( 1, $restrictions );
482 $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
483 $this->assertCount( 0, $restrictions );
495 $this->assertSame( $expected, $this->blockRestrictionStore->equals( $a, $b ) );
571 $this->assertSame( 1, $restrictions[1]->getBlockId() );
572 $this->assertSame( 1, $restrictions[2]->getBlockId() );
573 $this->assertSame( 1, $restrictions[3]->getBlockId() );
575 $result = $this->blockRestrictionStore->setBlockId( 2, $restrictions );
578 $this->assertSame( 2, $restriction->getBlockId() );
586 $block = new \Block( [
587 'address' => $badActor->getName(),
588 'user' => $badActor->getId(),
589 'by' => $sysop->getId(),
590 'expiry' =>
'infinity',
592 'enableAutoblock' =>
true,
601 $this->db->insert(
'ipblocks_restrictions', [
602 'ir_ipb_id' => $blockId,
609 $this->db->delete(
'ipblocks',
'*', __METHOD__ );
610 $this->db->delete(
'ipblocks_restrictions',
'*', __METHOD__ );