From f087bcb620b0a5674822a2320bdc443b5dce3b13 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 6 Jun 2015 20:55:03 +0200 Subject: [PATCH] Use assertSame in LogFormatterTestCase Using assertSame also checks for internal types to be correct. Needs the following fixes: - MergeLogFormatterTest: Use correct array key order - NewUsersLogFormatterTest: Input user id as integer - PatrolLogFormatter: Ensure in LogFormatter that integer is not casted to float Change-Id: I2cab5335d6654f6cda15fc4e9fbae2c1ca1b27ff --- includes/logging/LogFormatter.php | 2 +- tests/phpunit/includes/logging/LogFormatterTestCase.php | 2 +- tests/phpunit/includes/logging/MergeLogFormatterTest.php | 4 ++-- .../phpunit/includes/logging/NewUsersLogFormatterTest.php | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 119492be8c..0145b02f6b 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -790,7 +790,7 @@ class LogFormatter { break; case 'number': - if ( ctype_digit( $value ) ) { + if ( ctype_digit( $value ) || is_int( $value ) ) { $value = (int)$value; } else { $value = (float)$value; diff --git a/tests/phpunit/includes/logging/LogFormatterTestCase.php b/tests/phpunit/includes/logging/LogFormatterTestCase.php index e58711ff65..cab6794c3d 100644 --- a/tests/phpunit/includes/logging/LogFormatterTestCase.php +++ b/tests/phpunit/includes/logging/LogFormatterTestCase.php @@ -17,7 +17,7 @@ abstract class LogFormatterTestCase extends MediaWikiLangTestCase { 'Action text is equal to expected text' ); - $this->assertEquals( + $this->assertSame( // ensure types and array key order $extra['api'], self::removeApiMetaData( $formatter->formatParametersForApi() ), 'Api log params is equal to expected array' diff --git a/tests/phpunit/includes/logging/MergeLogFormatterTest.php b/tests/phpunit/includes/logging/MergeLogFormatterTest.php index 5a0b906ab5..2ff0ddf5e9 100644 --- a/tests/phpunit/includes/logging/MergeLogFormatterTest.php +++ b/tests/phpunit/includes/logging/MergeLogFormatterTest.php @@ -25,9 +25,9 @@ class MergeLogFormatterTest extends LogFormatterTestCase { array( 'text' => 'User merged OldPage into NewPage (revisions up to 16:07, 4 August 2014)', 'api' => array( - 'mergepoint' => '2014-08-04T16:07:10Z', 'dest_ns' => 0, 'dest_title' => 'NewPage', + 'mergepoint' => '2014-08-04T16:07:10Z', ), ), ), @@ -49,9 +49,9 @@ class MergeLogFormatterTest extends LogFormatterTestCase { 'legacy' => true, 'text' => 'User merged OldPage into NewPage (revisions up to 16:07, 4 August 2014)', 'api' => array( - 'mergepoint' => '2014-08-04T16:07:10Z', 'dest_ns' => 0, 'dest_title' => 'NewPage', + 'mergepoint' => '2014-08-04T16:07:10Z', ), ), ), diff --git a/tests/phpunit/includes/logging/NewUsersLogFormatterTest.php b/tests/phpunit/includes/logging/NewUsersLogFormatterTest.php index 13dd839fa8..5b03370d53 100644 --- a/tests/phpunit/includes/logging/NewUsersLogFormatterTest.php +++ b/tests/phpunit/includes/logging/NewUsersLogFormatterTest.php @@ -71,7 +71,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase { 'namespace' => NS_USER, 'title' => 'New user', 'params' => array( - '4::userid' => '1', + '4::userid' => 1, ), ), array( @@ -109,7 +109,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase { 'namespace' => NS_USER, 'title' => 'UTSysop', 'params' => array( - '4::userid' => '1', + '4::userid' => 1, ), ), array( @@ -147,7 +147,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase { 'namespace' => NS_USER, 'title' => 'UTSysop', 'params' => array( - '4::userid' => '1', + '4::userid' => 1, ), ), array( @@ -185,7 +185,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase { 'namespace' => NS_USER, 'title' => 'New user', 'params' => array( - '4::userid' => '1', + '4::userid' => 1, ), ), array( -- 2.20.1