forked from JeroenDeDauw/Wikibase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Null change op implementation"
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() ); | ||
} | ||
|
||
} |