jenkins-bot has submitted this change and it was merged.

Change subject: Fix exception checking in test cases
......................................................................


Fix exception checking in test cases

Also fixes some broken tests.

Change-Id: I1bb11e7bc7676caba3f9bee6c335df492933a71b
---
M DataValues/tests/phpunit/includes/DataValueTest.php
M DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
M DataValues/tests/phpunit/includes/values/QuantityValueTest.php
M DataValues/tests/phpunit/includes/values/TimeValueTest.php
4 files changed, 23 insertions(+), 18 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DataValues/tests/phpunit/includes/DataValueTest.php 
b/DataValues/tests/phpunit/includes/DataValueTest.php
index c97e717..63741b0 100644
--- a/DataValues/tests/phpunit/includes/DataValueTest.php
+++ b/DataValues/tests/phpunit/includes/DataValueTest.php
@@ -99,22 +99,16 @@
                $valid = array_shift( $args );
                $pokemons = null;
 
-               try {
-                       $dataItem = call_user_func_array( array( $this, 
'newInstance' ), $args );
-                       $this->assertInstanceOf( $this->getClass(), $dataItem );
+               if ( $valid === false ) {
+                       $valid = 'Exception';
                }
-               catch ( \Exception $pokemons ) {
-                       if ( $valid === true ) {
-                               throw $pokemons;
-                       }
 
-                       if ( is_string( $valid ) ) {
-                               $this->assertEquals( $valid, get_class( 
$pokemons ) );
-                       }
-                       else {
-                               $this->assertFalse( $valid );
-                       }
+               if ( is_string( $valid ) ) {
+                       $this->setExpectedException( $valid );
                }
+
+               $dataItem = call_user_func_array( array( $this, 'newInstance' 
), $args );
+               $this->assertInstanceOf( $this->getClass(), $dataItem );
        }
 
        /**
diff --git 
a/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php 
b/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
index a0e24aa..4e48050 100644
--- a/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
+++ b/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
@@ -56,6 +56,7 @@
        public function constructorProvider() {
                $argLists = array();
 
+               // #0
                $argLists[] = array( false );
                $argLists[] = array( false, 42 );
                $argLists[] = array( false, array() );
@@ -65,6 +66,7 @@
                $argLists[] = array( false, 'foo' );
                $argLists[] = array( false, 42 );
 
+               // #8
                $argLists[] = array( false, 'en', 42 );
                $argLists[] = array( false, 'en', 4.2 );
                $argLists[] = array( false, 42, false );
@@ -73,6 +75,7 @@
                $argLists[] = array( false, 42, 'foo' );
                $argLists[] = array( false, 4.2, 'foo' );
 
+               // #15
                $argLists[] = array( true, 4.2, 4.2 );
                $argLists[] = array( true, 4.2, 42 );
                $argLists[] = array( true, 42, 4.2 );
@@ -82,6 +85,7 @@
                $argLists[] = array( true, -42, 4.2 );
                $argLists[] = array( true, 0, 0 );
 
+               // #23
                $argLists[] = array( false, '4.2', 4.2 );
                $argLists[] = array( false, '4.2', '4.2' );
                $argLists[] = array( false, 4.2, '4.2' );
@@ -89,27 +93,31 @@
                $argLists[] = array( false, 42, '42' );
                $argLists[] = array( false, '0', 0 );
 
+               // #29
                $argLists[] = array( true, 4.2, 4.2, 4.2 );
                $argLists[] = array( true, 4.2, -4.2, -42 );
                $argLists[] = array( true, -42, 4.2, 42 );
                $argLists[] = array( true, -4.2, 42, -4.2 );
                $argLists[] = array( true, 0, 0, 0 );
 
+               // #34
                $argLists[] = array( false, 4.2, 4.2, '4.2' );
                $argLists[] = array( false, 4.2, '4.2', 4.2 );
                $argLists[] = array( false, '4.2', 4.2, 4.2 );
                $argLists[] = array( false, 42, 4.2, false );
                $argLists[] = array( false, 42, 4.2, true );
-               $argLists[] = array( false, 42, 4.2, null );
+               $argLists[] = array( true, 42, 4.2, null );
                $argLists[] = array( false, 42, 4.2, array() );
                $argLists[] = array( false, 42, 4.2, 'foo' );
 
+               // #42
                $argLists[] = array( true, 42, 4.2, 9000.1, 
'http://www.wikidata.org/entity/Q2' );
                $argLists[] = array( true, 42, 4.2, 9000.1, null );
                $argLists[] = array( true, 4.2, 42, 9000.1, 'terminus' );
                $argLists[] = array( true, 4.2, 42, 0, "Schar's World" );
                $argLists[] = array( true, -42, -4.2, -9000.1, 'coruscant' );
 
+               // #47
                $argLists[] = array( false, 42, 4.2, 9000.1, false );
                $argLists[] = array( false, 42, 4.2, 9000.1, true );
                $argLists[] = array( false, 42, 4.2, 9000.1, 42 );
diff --git a/DataValues/tests/phpunit/includes/values/QuantityValueTest.php 
b/DataValues/tests/phpunit/includes/values/QuantityValueTest.php
index da9509c..81b2c09 100644
--- a/DataValues/tests/phpunit/includes/values/QuantityValueTest.php
+++ b/DataValues/tests/phpunit/includes/values/QuantityValueTest.php
@@ -56,6 +56,7 @@
        public function constructorProvider() {
                $argLists = array();
 
+               // #0
                $argLists[] = array( false );
 
                $argLists[] = array( true, 42 );
@@ -75,6 +76,7 @@
                $argLists[] = array( false, null );
                $argLists[] = array( false, '0x20' );
 
+               // #17
                $argLists[] = array( true, 42, 'm' );
                $argLists[] = array( true, -42, 'm' );
                $argLists[] = array( true, 4.2, 'm' );
@@ -85,19 +87,20 @@
                $argLists[] = array( false, '0', 'm' );
                $argLists[] = array( false, 42, 0 );
                $argLists[] = array( false, -42, 0 );
-               $argLists[] = array( false, 4.2, null );
+               $argLists[] = array( true, 4.2, null );
                $argLists[] = array( false, -4.2, false );
                $argLists[] = array( false, 0, true );
                $argLists[] = array( false, 'foo', array() );
                $argLists[] = array( false, '', 4.2 );
                $argLists[] = array( false, '0', -1 );
 
+               // #33
                $argLists[] = array( true, 42, 'm', 4.2 );
                $argLists[] = array( true, -42, 'm', -4.2 );
                $argLists[] = array( true, 4.2, 'm', -42 );
                $argLists[] = array( true, -4.2, 'm', 42 );
                $argLists[] = array( false, 42, 'm', false );
-               $argLists[] = array( false, -42, 'm', null );
+               $argLists[] = array( true, -42, 'm', null );
                $argLists[] = array( false, 4.2, 'm', '0' );
                $argLists[] = array( false, -4.2, 'm', '-4.2' );
 
diff --git a/DataValues/tests/phpunit/includes/values/TimeValueTest.php 
b/DataValues/tests/phpunit/includes/values/TimeValueTest.php
index c4e3a5e..e698eea 100644
--- a/DataValues/tests/phpunit/includes/values/TimeValueTest.php
+++ b/DataValues/tests/phpunit/includes/values/TimeValueTest.php
@@ -117,12 +117,12 @@
                );
 
                $argLists[] = array(
-                       'DataValues\IllegalValueException',
+                       true,
                        '+00000002013-01-01T00:00:00Z',
                        0,
                        0,
                        0,
-                       0,
+                       0, // 0 == TimeValue::PRECISION_GIGAYEAR
                        'http://nyan.cat/original.php',
                );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/67813
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1bb11e7bc7676caba3f9bee6c335df492933a71b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to