<?php
use MediaWiki\Linker\LinkTarget;
-use Wikimedia\Rdbms\LoadBalancer;
use Wikimedia\Rdbms\LBFactory;
+use Wikimedia\Rdbms\LoadBalancer;
use Wikimedia\ScopedCallback;
use Wikimedia\TestingAccessWrapper;
]
);
+ $mockDb->expects( $this->once() )
+ ->method( 'affectedRows' )
+ ->willReturn( 2 );
+
$mockCache = $this->getMockCache();
$mockCache->expects( $this->exactly( 2 ) )
->method( 'delete' );
$mockDb = $this->getMockDb();
$mockDb->expects( $this->once() )
->method( 'delete' )
- ->with(
- 'watchlist',
+ ->withConsecutive(
[
- 'wl_user' => 1,
- 'wl_namespace' => 0,
- 'wl_title' => 'SomeDbKey',
+ 'watchlist',
+ [
+ 'wl_user' => 1,
+ 'wl_namespace' => 0,
+ 'wl_title' => [ 'SomeDbKey' ],
+ ],
+ ],
+ [
+ 'watchlist',
+ [
+ 'wl_user' => 1,
+ 'wl_namespace' => 1,
+ 'wl_title' => [ 'SomeDbKey' ],
+ ]
]
);
- $mockDb->expects( $this->once() )
+ $mockDb->expects( $this->exactly( 1 ) )
->method( 'affectedRows' )
- ->will( $this->returnValue( 1 ) );
+ ->willReturn( 2 );
$mockCache = $this->getMockCache();
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->once() )
->method( 'delete' )
- ->with( '0:SomeDbKey:1' );
+ ->withConsecutive(
+ [ '0:SomeDbKey:1' ],
+ [ '1:SomeDbKey:1' ]
+ );
$store = $this->newWatchedItemStore(
$this->getMockLBFactory( $mockDb ),
$this->getMockReadOnlyMode()
);
+ $titleValue = new TitleValue( 0, 'SomeDbKey' );
$this->assertTrue(
$store->removeWatch(
$this->getMockNonAnonUserWithId( 1 ),
- new TitleValue( 0, 'SomeDbKey' )
+ Title::newFromTitleValue( $titleValue )
)
);
}
$mockDb = $this->getMockDb();
$mockDb->expects( $this->once() )
->method( 'delete' )
- ->with(
- 'watchlist',
+ ->withConsecutive(
[
- 'wl_user' => 1,
- 'wl_namespace' => 0,
- 'wl_title' => 'SomeDbKey',
+ 'watchlist',
+ [
+ 'wl_user' => 1,
+ 'wl_namespace' => 0,
+ 'wl_title' => [ 'SomeDbKey' ],
+ ]
+ ],
+ [
+ 'watchlist',
+ [
+ 'wl_user' => 1,
+ 'wl_namespace' => 1,
+ 'wl_title' => [ 'SomeDbKey' ],
+ ]
]
);
+
$mockDb->expects( $this->once() )
->method( 'affectedRows' )
- ->will( $this->returnValue( 0 ) );
+ ->willReturn( 0 );
$mockCache = $this->getMockCache();
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->once() )
->method( 'delete' )
- ->with( '0:SomeDbKey:1' );
+ ->withConsecutive(
+ [ '0:SomeDbKey:1' ],
+ [ '1:SomeDbKey:1' ]
+ );
$store = $this->newWatchedItemStore(
$this->getMockLBFactory( $mockDb ),
$this->getMockReadOnlyMode()
);
+ $titleValue = new TitleValue( 0, 'SomeDbKey' );
$this->assertFalse(
$store->removeWatch(
$this->getMockNonAnonUserWithId( 1 ),
- new TitleValue( 0, 'SomeDbKey' )
+ Title::newFromTitleValue( $titleValue )
)
);
}