From 2cad416fe71d7a0a3f6b1cdf87ffac20cb295656 Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 18 Apr 2016 12:32:46 +0100 Subject: [PATCH] Test coverage WatchedItemStore::duplicateAllAssociatedEntries to 100% Change-Id: I3d686fda1175a9ae5e4244b9ba8cfdb416950ebd --- .../includes/WatchedItemStoreUnitTest.php | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/includes/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/WatchedItemStoreUnitTest.php index 9b3e798d50..17b2fa4a0c 100644 --- a/tests/phpunit/includes/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/WatchedItemStoreUnitTest.php @@ -813,7 +813,20 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { ); } - public function testDuplicateAllAssociatedEntries_somethingToDuplicate() { + public function provideLinkTargetPairs() { + return [ + [ Title::newFromText( 'Old_Title' ), Title::newFromText( 'New_Title' ) ], + [ new TitleValue( 0, 'Old_Title' ), new TitleValue( 0, 'New_Title' ) ], + ]; + } + + /** + * @dataProvider provideLinkTargetPairs + */ + public function testDuplicateAllAssociatedEntries_somethingToDuplicate( + LinkTarget $oldTarget, + LinkTarget $newTarget + ) { $fakeRows = [ $this->getFakeRow( [ 'wl_user' => 1, 'wl_notificationtimestamp' => '20151212010101' ] ), ]; @@ -828,8 +841,8 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { 'wl_notificationtimestamp', ], [ - 'wl_namespace' => 0, - 'wl_title' => 'Old_Title', + 'wl_namespace' => $oldTarget->getNamespace(), + 'wl_title' => $oldTarget->getDBkey(), ] ) ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) ); @@ -841,8 +854,8 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { [ [ 'wl_user' => 1, - 'wl_namespace' => 0, - 'wl_title' => 'New_Title', + 'wl_namespace' => $newTarget->getNamespace(), + 'wl_title' => $newTarget->getDBkey(), 'wl_notificationtimestamp' => '20151212010101', ], ], @@ -857,8 +870,8 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { 'wl_notificationtimestamp', ], [ - 'wl_namespace' => 1, - 'wl_title' => 'Old_Title', + 'wl_namespace' => $oldTarget->getNamespace() + 1, + 'wl_title' => $oldTarget->getDBkey(), ] ) ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) ); @@ -870,8 +883,8 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { [ [ 'wl_user' => 1, - 'wl_namespace' => 1, - 'wl_title' => 'New_Title', + 'wl_namespace' => $newTarget->getNamespace() + 1, + 'wl_title' => $newTarget->getDBkey(), 'wl_notificationtimestamp' => '20151212010101', ], ], @@ -888,8 +901,8 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { ); $store->duplicateAllAssociatedEntries( - Title::newFromText( 'Old_Title' ), - Title::newFromText( 'New_Title' ) + $oldTarget, + $newTarget ); } -- 2.20.1