jenkins-bot has submitted this change and it was merged.
Change subject: Fix pass by ref in object comparer and add tests
......................................................................
Fix pass by ref in object comparer and add tests
ObjectComparer wanted to pass things by reference
for some reason which fails PHP STRICT so this is
removed
Also added some simple tests for the class
Change-Id: I2653426355b99913d0a85be104545edbd5d379f6
---
M DataModel/Internal/ObjectComparer.php
A tests/phpunit/Internal/ObjectComparerTest.php
2 files changed, 51 insertions(+), 1 deletion(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
jenkins-bot: Verified
diff --git a/DataModel/Internal/ObjectComparer.php
b/DataModel/Internal/ObjectComparer.php
index fab730e..5dc59ca 100644
--- a/DataModel/Internal/ObjectComparer.php
+++ b/DataModel/Internal/ObjectComparer.php
@@ -36,7 +36,7 @@
*
* @return bool
*/
- public function dataEquals( &$a, &$b, $skip = null ) {
+ public function dataEquals( $a, $b, $skip = null ) {
if ( is_array( $a ) ) {
if ( !is_array( $b ) ) {
return false;
diff --git a/tests/phpunit/Internal/ObjectComparerTest.php
b/tests/phpunit/Internal/ObjectComparerTest.php
new file mode 100644
index 0000000..903574e
--- /dev/null
+++ b/tests/phpunit/Internal/ObjectComparerTest.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Wikibase\Test;
+
+use Wikibase\DataModel\Internal\ObjectComparer;
+
+/**
+ * @covers Wikibase\DataModel\Internal\ObjectComparer
+ *
+ * @licence GNU GPL v2+
+ * @author Adam Shorland
+ */
+class ObjectComparerTest extends \PHPUnit_Framework_TestCase {
+
+ public static function provideDataEquals(){
+ return array(
+ //equals
+ array( null, null, true ),
+ array( array(), array(), true ),
+ array( array( 'foo' ), array( 'foo' ), true ),
+ array( array( 'bar' => 'foo' ), array( 'bar' => 'foo'
), true ),
+ array( true, true, true ),
+ array( 100, 100, true ),
+ array( 'abc', 'abc', true ),
+ array( new \Exception(), new \Exception(), true ),
+ array( new \Exception( 'foo' ), new \Exception( 'foo'
), true ),
+ //notequals
+ array( array(), array( 'foo' ), false ),
+ array( array( 'foo' ), array( 'foo2' ), false ),
+ array( array( 'bar2' => 'foo' ), array( 'bar' => 'foo'
), false ),
+ array( array( 'bar' => 'foo2' ), array( 'bar' => 'foo'
), false ),
+ array( true, false, false ),
+ array( 100, 101, false ),
+ array( 'abc', 'abcc', false ),
+ array( new \Exception(), null, false ),
+ array( new \Exception( 'foo2' ), new \Exception( 'foo'
), true ),
+ array( false, null, false ),
+ );
+ }
+
+ /**
+ * @dataProvider provideDataEquals
+ */
+ public function testDataEquals( $a, $b, $expected ){
+ $comparer = new ObjectComparer();
+ $result = $comparer->dataEquals( $a, $b );
+ $this->assertEquals( $expected, $result );
+ }
+
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/94135
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2653426355b99913d0a85be104545edbd5d379f6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseDataModel
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits