jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/330872 )
Change subject: Null change op implementation
......................................................................
Null change op implementation
Change-Id: I80a2058359203c9df364b2953fe3eabd78f18e10
---
A repo/includes/ChangeOp/NullChangeOp.php
A repo/tests/phpunit/includes/ChangeOp/NullChangeOpTest.php
2 files changed, 69 insertions(+), 0 deletions(-)
Approvals:
WMDE-leszek: Looks good to me, approved
Ladsgroup: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/repo/includes/ChangeOp/NullChangeOp.php
b/repo/includes/ChangeOp/NullChangeOp.php
new file mode 100644
index 0000000..60fcf58
--- /dev/null
+++ b/repo/includes/ChangeOp/NullChangeOp.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Wikibase\Repo\ChangeOp;
+
+use ValueValidators\Result;
+use Wikibase\ChangeOp\ChangeOp;
+use Wikibase\DataModel\Entity\EntityDocument;
+use Wikibase\Summary;
+
+/**
+ * @license GPL-2.0+
+ */
+class NullChangeOp implements ChangeOp {
+
+ /**
+ * @see ChangeOp::validate()
+ */
+ public function validate( EntityDocument $entity ) {
+ return Result::newSuccess();
+ }
+
+ /**
+ * @see ChangeOp::apply()
+ */
+ public function apply( EntityDocument $entity, Summary $summary = null
) {
+ // no op
+ }
+
+}
diff --git a/repo/tests/phpunit/includes/ChangeOp/NullChangeOpTest.php
b/repo/tests/phpunit/includes/ChangeOp/NullChangeOpTest.php
new file mode 100644
index 0000000..def7e2f
--- /dev/null
+++ b/repo/tests/phpunit/includes/ChangeOp/NullChangeOpTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Wikibase\Repo\Tests\ChangeOp;
+
+use PHPUnit_Framework_MockObject_MockObject;
+use Wikibase\DataModel\Entity\EntityDocument;
+use Wikibase\Repo\ChangeOp\NullChangeOp;
+
+/**
+ * @covers Wikibase\Repo\ChangeOp\NullChangeOp
+ *
+ * @group Wikibase
+ * @license GPL-2.0+
+ */
+class NullChangeOpTest extends \PHPUnit_Framework_TestCase {
+
+ public function testReturnsValidResult_WhenValidatesEntityDocument() {
+ /** @var EntityDocument $entityDocument */
+ $entityDocument = $this->getMock( EntityDocument::class );
+ $nullChangeOp = new NullChangeOp();
+
+ $result = $nullChangeOp->validate( $entityDocument );
+
+ self::assertTrue( $result->isValid() );
+ }
+
+ public function testDoesNotCallAnyMethodOnEntity_WhenApplied() {
+ /** @var EntityDocument|PHPUnit_Framework_MockObject_MockObject
$entityDocument */
+ $entityDocument = $this->getMock( EntityDocument::class );
+ $nullChangeOp = new NullChangeOp();
+
+ $this->expectNoMethodWillBeEverCalledOn( $entityDocument );
+ $nullChangeOp->apply( $entityDocument );
+ }
+
+ private function expectNoMethodWillBeEverCalledOn(
PHPUnit_Framework_MockObject_MockObject $entityMock ) {
+ $entityMock->expects( $this->never() )->method(
self::anything() );
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/330872
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I80a2058359203c9df364b2953fe3eabd78f18e10
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits