r79530 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79529‎ | r79530 | r79531 >
Date:21:14, 3 January 2011
Author:soxred93
Status:ok (Comments)
Tags:
Comment:
Add JSON test case
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/JsonTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/JsonTest.php
@@ -0,0 +1,33 @@
 2+<?php
 3+
 4+class JsonTest extends MediaWikiTestCase {
 5+
 6+ function testPHPBug46944Test() {
 7+
 8+ $this->assertNotEquals(
 9+ '\ud840\udc00',
 10+ strtolower( FormatJson::encode( "\xf0\xa0\x80\x80" ) ),
 11+ 'Test encoding an broken json_encode character (U+20000)'
 12+ );
 13+
 14+
 15+ }
 16+
 17+ function testDecodeVarTypes() {
 18+
 19+ $this->assertInternalType(
 20+ 'object',
 21+ FormatJson::decode( '{"Name": "Cheeso", "Rank": 7}' ),
 22+ 'Default to object'
 23+ );
 24+
 25+ $this->assertInternalType(
 26+ 'array',
 27+ FormatJson::decode( '{"Name": "Cheeso", "Rank": 7}', true ),
 28+ 'Optional array'
 29+ );
 30+
 31+ }
 32+
 33+}
 34+
Property changes on: trunk/phase3/tests/phpunit/includes/JsonTest.php
___________________________________________________________________
Added: svn:eol-style
135 + native

Comments

#Comment by RobLa-WMF (talk | contribs)   22:38, 3 January 2011

Should a single test have two assertions?

#Comment by Platonides (talk | contribs)   22:47, 3 January 2011

Seems good to me. We want all of them to pass. Note that we have other tests with many assertions.

#Comment by X! (talk | contribs)   01:35, 4 January 2011

If the two assertions are almost the same, then yes.

Status & tagging log