assertSame() is guaranteed to never do any magic type conversion.
This can be critical when accidentially comparing empty strings (a
value PHP considers to be "falsy") to false, 0, 0.0, null, and such.
Change-Id: I2e2685c5992cae252f629a68ffe1a049f2e5ed1b
18 files changed:
- $this->assertEquals( '', $bad );
+ $this->assertSame( '', $bad );
public function testGetText() {
$req = new FauxRequest( [ 'x' => 'Value' ] );
$this->assertEquals( 'Value', $req->getText( 'x' ) );
public function testGetText() {
$req = new FauxRequest( [ 'x' => 'Value' ] );
$this->assertEquals( 'Value', $req->getText( 'x' ) );
- $this->assertEquals( '', $req->getText( 'z' ) );
+ $this->assertSame( '', $req->getText( 'z' ) );
*/
public function testDummies() {
$req = new FauxRequest();
*/
public function testDummies() {
$req = new FauxRequest();
- $this->assertEquals( '', $req->getRawQueryString() );
- $this->assertEquals( '', $req->getRawPostString() );
- $this->assertEquals( '', $req->getRawInput() );
+ $this->assertSame( '', $req->getRawQueryString() );
+ $this->assertSame( '', $req->getRawPostString() );
+ $this->assertSame( '', $req->getRawInput() );
* @covers Html::expandAttributes
*/
public function testExpandAttributesForBooleans() {
* @covers Html::expandAttributes
*/
public function testExpandAttributesForBooleans() {
'',
Html::expandAttributes( [ 'selected' => false ] ),
'Boolean attributes do not generates output when value is false'
);
'',
Html::expandAttributes( [ 'selected' => false ] ),
'Boolean attributes do not generates output when value is false'
);
'',
Html::expandAttributes( [ 'selected' => null ] ),
'Boolean attributes do not generates output when value is null'
'',
Html::expandAttributes( [ 'selected' => null ] ),
'Boolean attributes do not generates output when value is null'
$this->assertNull( Xml::expandAttributes( null ),
'Converting a null list of attributes'
);
$this->assertNull( Xml::expandAttributes( null ),
'Converting a null list of attributes'
);
- $this->assertEquals( '', Xml::expandAttributes( [] ),
+ $this->assertSame( '', Xml::expandAttributes( [] ),
'Converting an empty list of attributes'
);
}
'Converting an empty list of attributes'
);
}
$recentChange2 = $this->getEditChange( '20131103092253' );
$html = $enhancedChangesList->recentChangesLine( $recentChange2, false );
$recentChange2 = $this->getEditChange( '20131103092253' );
$html = $enhancedChangesList->recentChangesLine( $recentChange2, false );
- $this->assertEquals( '', $html );
+ $this->assertSame( '', $html );
}
public function testRecentChangesPrefix() {
}
public function testRecentChangesPrefix() {
$content = null;
$text = ContentHandler::getContentText( $content );
$content = null;
$text = ContentHandler::getContentText( $content );
- $this->assertEquals( '', $text );
+ $this->assertSame( '', $text );
}
public static function dataGetContentText_TextContent() {
}
public static function dataGetContentText_TextContent() {
$content = $handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
$content = $handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
- $this->assertEquals( '', $content->getData() );
+ $this->assertSame( '', $content->getData() );
}
public static function dataIsSupportedFormat() {
}
public static function dataIsSupportedFormat() {
public function testGetWikitextForTransclusion() {
$content = $this->newContent( 'hello world.' );
public function testGetWikitextForTransclusion() {
$content = $this->newContent( 'hello world.' );
- $this->assertEquals( '', $content->getWikitextForTransclusion() );
+ $this->assertFalse( $content->getWikitextForTransclusion() );
$content = $this->handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
$content = $this->handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
- $this->assertEquals( '', $content->getText() );
+ $this->assertSame( '', $content->getText() );
}
public static function dataIsSupportedFormat() {
}
public static function dataIsSupportedFormat() {
/** @var IMaintainableDatabase $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
/** @var IMaintainableDatabase $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
'',
$db->getDomainId(),
'Null domain ID handle used'
);
'',
$db->getDomainId(),
'Null domain ID handle used'
);
- $this->assertEquals(
- '',
$db->getDBname(),
'Null domain ID handle used'
);
$db->getDBname(),
'Null domain ID handle used'
);
'',
$db->tablePrefix(),
'Main domain ID handle used; prefix is empty though'
'',
$db->tablePrefix(),
'Main domain ID handle used; prefix is empty though'
/** @var IMaintainableDatabase $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
/** @var IMaintainableDatabase $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
- $this->assertEquals( '', $db->getDomainID(), "Null domain used" );
+ $this->assertSame( '', $db->getDomainID(), "Null domain used" );
$this->assertEquals(
$this->quoteTable( $db, 'page' ),
$this->assertEquals(
$this->quoteTable( $db, 'page' ),
* @covers File::getHashPath
*/
public function testGetHashPath() {
* @covers File::getHashPath
*/
public function testGetHashPath() {
- $this->assertEquals( '', $this->file_hl0->getHashPath() );
+ $this->assertSame( '', $this->file_hl0->getHashPath() );
$this->assertEquals( 'a/a2/', $this->file_hl2->getHashPath() );
$this->assertEquals( 'c/c4/', $this->file_lc->getHashPath() );
}
$this->assertEquals( 'a/a2/', $this->file_hl2->getHashPath() );
$this->assertEquals( 'c/c4/', $this->file_lc->getHashPath() );
}
$this->hideDeprecated( 'Http::getProxy' );
$this->setMwGlobals( 'wgHTTPProxy', false );
$this->hideDeprecated( 'Http::getProxy' );
$this->setMwGlobals( 'wgHTTPProxy', false );
'',
Http::getProxy(),
'default setting'
'',
Http::getProxy(),
'default setting'
$linkRenderer = new LinkRenderer( $titleFormatter, $linkCache, $nsInfo );
$linkRenderer->setStubThreshold( 0 );
$linkRenderer = new LinkRenderer( $titleFormatter, $linkCache, $nsInfo );
$linkRenderer->setStubThreshold( 0 );
'',
$linkRenderer->getLinkClasses( $foobarTitle )
);
'',
$linkRenderer->getLinkClasses( $foobarTitle )
);
);
$linkRenderer->setStubThreshold( 20 );
);
$linkRenderer->setStubThreshold( 20 );
'',
$linkRenderer->getLinkClasses( $userTitle )
);
'',
$linkRenderer->getLinkClasses( $userTitle )
);
] );
$context = $this->getResourceLoaderContext( [], $rl );
] );
$context = $this->getResourceLoaderContext( [], $rl );
'',
$rl->getCombinedVersion( $context, [] ),
'empty list'
'',
$rl->getCombinedVersion( $context, [] ),
'empty list'
$path = '//acme.com/'; // protocol-relative URL
$site->setPath( $type, $path );
$path = '//acme.com/'; // protocol-relative URL
$site->setPath( $type, $path );
- $this->assertEquals( '', $site->getProtocol() );
+ $this->assertSame( '', $site->getProtocol() );
}
public static function provideGetPageUrl() {
}
public static function provideGetPageUrl() {
$s = $lang->getMessageFromDB( 'word-separator' );
$c = $lang->getMessageFromDB( 'comma-separator' );
$s = $lang->getMessageFromDB( 'word-separator' );
$c = $lang->getMessageFromDB( 'comma-separator' );
- $this->assertEquals( '', $lang->listToText( [] ) );
+ $this->assertSame( '', $lang->listToText( [] ) );
$this->assertEquals( 'a', $lang->listToText( [ 'a' ] ) );
$this->assertEquals( "a{$and}{$s}b", $lang->listToText( [ 'a', 'b' ] ) );
$this->assertEquals( "a{$c}b{$and}{$s}c", $lang->listToText( [ 'a', 'b', 'c' ] ) );
$this->assertEquals( 'a', $lang->listToText( [ 'a' ] ) );
$this->assertEquals( "a{$and}{$s}b", $lang->listToText( [ 'a', 'b' ] ) );
$this->assertEquals( "a{$c}b{$and}{$s}c", $lang->listToText( [ 'a', 'b', 'c' ] ) );
// 2. Do the real output checking on our own.
$lines = explode( "\n", $this->getActualOutput() );
$this->assertGreaterThan( 1, count( $lines ), "Minimal lines of produced output" );
// 2. Do the real output checking on our own.
$lines = explode( "\n", $this->getActualOutput() );
$this->assertGreaterThan( 1, count( $lines ), "Minimal lines of produced output" );
- $this->assertEquals( '', array_pop( $lines ), "Output ends in LF" );
+ $this->assertSame( '', array_pop( $lines ), "Output ends in LF" );
$timestamp_re = "[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-6][0-9]";
foreach ( $lines as $line ) {
$this->assertRegExp(
$timestamp_re = "[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-6][0-9]";
foreach ( $lines as $line ) {
$this->assertRegExp(
public function testConstruct() {
$pf = new PasswordFactory();
$this->assertEquals( [ '' ], array_keys( $pf->getTypes() ) );
public function testConstruct() {
$pf = new PasswordFactory();
$this->assertEquals( [ '' ], array_keys( $pf->getTypes() ) );
- $this->assertEquals( '', $pf->getDefaultType() );
+ $this->assertSame( '', $pf->getDefaultType() );
$pf = new PasswordFactory( [
'foo' => [ 'class' => 'FooPassword' ],
$pf = new PasswordFactory( [
'foo' => [ 'class' => 'FooPassword' ],