jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/398815 )
Change subject: Avoid using EntityDiffChangedAspectsFactory like a static
constructor
......................................................................
Avoid using EntityDiffChangedAspectsFactory like a static constructor
This follows Id17259c, which was rebased multiple times and did not
touched all cases because of these rebases.
This patch also fixes the class autoloading. Without these additional
lines I can not run the ItemChangeTest locally.
Bug: T113468
Change-Id: I8a4acb47930a1c911750274ec9a2ccd5330b0491
---
M client/tests/phpunit/includes/Changes/InjectRCRecordsJobTest.php
M client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php
M lib/autoload.php
M lib/tests/phpunit/Changes/ItemChangeTest.php
M repo/tests/phpunit/includes/Store/Sql/SqlChangeStoreTest.php
5 files changed, 11 insertions(+), 20 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/tests/phpunit/includes/Changes/InjectRCRecordsJobTest.php
b/client/tests/phpunit/includes/Changes/InjectRCRecordsJobTest.php
index e8bdd4e..f4db267 100644
--- a/client/tests/phpunit/includes/Changes/InjectRCRecordsJobTest.php
+++ b/client/tests/phpunit/includes/Changes/InjectRCRecordsJobTest.php
@@ -13,11 +13,10 @@
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Services\Diff\EntityDiffer;
-use Wikibase\DataModel\Services\Diff\ItemDiff;
use Wikibase\EntityChange;
use Wikibase\ItemChange;
use Wikibase\Lib\Changes\EntityChangeFactory;
-use Wikibase\Lib\Changes\EntityDiffChangedAspectsFactory;
+use Wikibase\Lib\Changes\EntityDiffChangedAspects;
use Wikibase\Lib\Store\Sql\EntityChangeLookup;
use Wikimedia\Rdbms\LBFactory;
use Wikimedia\TestingAccessWrapper;
@@ -219,7 +218,7 @@
'object_id' => $itemId->getSerialization(),
] );
- $diff = ( new EntityDiffChangedAspectsFactory()
)->newFromEntityDiff( new ItemDiff() );
+ $diff = EntityDiffChangedAspects::newEmpty();
return [
'mock change' => [
diff --git
a/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php
b/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php
index b60a22e..affc250 100644
--- a/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php
+++ b/client/tests/phpunit/includes/RecentChanges/RecentChangeFactoryTest.php
@@ -8,7 +8,7 @@
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Services\Diff\ItemDiffer;
use Wikibase\DataModel\SiteLink;
-use Wikibase\Lib\Changes\EntityDiffChangedAspectsFactory;
+use Wikibase\Lib\Changes\EntityDiffChangedAspects;
use Wikibase\Lib\Tests\Changes\MockRepoClientCentralIdLookup;
use SiteLookup;
use Wikimedia\TestingAccessWrapper;
@@ -71,10 +71,7 @@
// instantiate and handle the change
$type = 'wikibase-' . $entityId->getEntityType() . '~' .
$action;
$instance->setField( 'type', $type );
- $aspects = ( new EntityDiffChangedAspectsFactory()
)->newFromEntityDiff(
- $diff
- );
- $instance->setCompactDiff( $aspects );
+ $instance->setCompactDiff(
EntityDiffChangedAspects::newFromEntityDiff( $diff ) );
return $instance;
}
diff --git a/lib/autoload.php b/lib/autoload.php
index b5e441a..c47636a 100644
--- a/lib/autoload.php
+++ b/lib/autoload.php
@@ -158,6 +158,8 @@
'Wikibase\\Lib\\Store\\TypeDispatchingEntityStore' => __DIR__ .
'/includes/Store/TypeDispatchingEntityStore.php',
'Wikibase\\Lib\\Store\\WikiPagePropertyOrderProvider' => __DIR__ .
'/includes/Store/WikiPagePropertyOrderProvider.php',
'Wikibase\\Lib\\Store\\WikiTextPropertyOrderProvider' => __DIR__ .
'/includes/Store/WikiTextPropertyOrderProvider.php',
+ 'Wikibase\\Lib\\Tests\\Changes\\ChangeRowTest' => __DIR__ .
'/tests/phpunit/Changes/ChangeRowTest.php',
+ 'Wikibase\\Lib\\Tests\\Changes\\EntityChangeTest' => __DIR__ .
'/tests/phpunit/Changes/EntityChangeTest.php',
'Wikibase\\Lib\\Tests\\Changes\\MockRepoClientCentralIdLookup' =>
__DIR__ . '/tests/phpunit/Changes/MockRepoClientCentralIdLookup.php',
'Wikibase\\Lib\\Tests\\Changes\\TestChanges' => __DIR__ .
'/tests/phpunit/Changes/TestChanges.php',
'Wikibase\\Lib\\Tests\\EntityRevisionLookupTest' => __DIR__ .
'/tests/phpunit/EntityRevisionLookupTest.php',
diff --git a/lib/tests/phpunit/Changes/ItemChangeTest.php
b/lib/tests/phpunit/Changes/ItemChangeTest.php
index 67b2e7f..f035a39 100644
--- a/lib/tests/phpunit/Changes/ItemChangeTest.php
+++ b/lib/tests/phpunit/Changes/ItemChangeTest.php
@@ -8,7 +8,7 @@
use Wikibase\DataModel\Services\Diff\ItemDiff;
use Wikibase\EntityChange;
use Wikibase\ItemChange;
-use Wikibase\Lib\Changes\EntityDiffChangedAspectsFactory;
+use Wikibase\Lib\Changes\EntityDiffChangedAspects;
/**
* @covers Wikibase\ItemChange
@@ -72,9 +72,7 @@
// Make sure we can deal with that.
$change = new ItemChange( [ 'type' => 'test' ] );
- $change->setCompactDiff(
- ( new EntityDiffChangedAspectsFactory()
)->newFromEntityDiff( new Diff() )
- );
+ $change->setCompactDiff(
EntityDiffChangedAspects::newEmpty() );
$cases['plain-diff'] = [ $change ];
@@ -95,9 +93,7 @@
//NOTE: ItemChange's constructor may or may not already
fix the bad diff.
$change = new ItemChange( [ 'type' => 'test' ] );
- $change->setCompactDiff(
- ( new EntityDiffChangedAspectsFactory()
)->newFromEntityDiff( $diff )
- );
+ $change->setCompactDiff(
EntityDiffChangedAspects::newFromEntityDiff( $diff ) );
$cases['atomic-sitelink-diff'] = [ $change ];
} finally {
diff --git a/repo/tests/phpunit/includes/Store/Sql/SqlChangeStoreTest.php
b/repo/tests/phpunit/includes/Store/Sql/SqlChangeStoreTest.php
index 46432aa..13021f3 100644
--- a/repo/tests/phpunit/includes/Store/Sql/SqlChangeStoreTest.php
+++ b/repo/tests/phpunit/includes/Store/Sql/SqlChangeStoreTest.php
@@ -3,10 +3,9 @@
namespace Wikibase\Repo\Tests\Store\Sql;
use RecentChange;
-use Diff\DiffOp\Diff\Diff;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\EntityChange;
-use Wikibase\Lib\Changes\EntityDiffChangedAspectsFactory;
+use Wikibase\Lib\Changes\EntityDiffChangedAspects;
use Wikibase\Repo\Store\Sql\SqlChangeStore;
use Wikibase\Repo\WikibaseRepo;
@@ -34,9 +33,7 @@
$changeWithDiff = $factory->newForEntity( EntityChange::REMOVE,
new ItemId( 'Q42' ) );
$changeWithDiff->setField( 'time', $time );
- $changeWithDiff->setCompactDiff(
- ( new EntityDiffChangedAspectsFactory()
)->newFromEntityDiff( new Diff() )
- );
+ $changeWithDiff->setCompactDiff(
EntityDiffChangedAspects::newEmpty() );
$rc = new RecentChange();
$rc->setAttribs( [
--
To view, visit https://gerrit.wikimedia.org/r/398815
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8a4acb47930a1c911750274ec9a2ccd5330b0491
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Kreuz (WMDE) <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Thiemo Kreuz (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits