Aleksey Bekh-Ivanov (WMDE) has uploaded a new change for review. (
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, 68 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/72/330872/1
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..c19adae
--- /dev/null
+++ b/repo/tests/phpunit/includes/ChangeOp/NullChangeOpTest.php
@@ -0,0 +1,39 @@
+<?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
+ *
+ * @license GPL-2.0+
+ */
+class NullChangeOpTest extends \PHPUnit_Framework_TestCase {
+
+ public function testReturnsValidResult_WhenValidatesEntityDocument() {
+ /** @var EntityDocument|PHPUnit_Framework_MockObject_MockObject
$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: newchange
Gerrit-Change-Id: I80a2058359203c9df364b2953fe3eabd78f18e10
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits