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
}
}
- $this->assertEquals( '', $bad );
+ $this->assertSame( '', $bad );
}
}
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();
- $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() {
- $this->assertEquals(
+ $this->assertSame(
'',
Html::expandAttributes( [ 'selected' => false ] ),
'Boolean attributes do not generates output when value is false'
);
- $this->assertEquals(
+ $this->assertSame(
'',
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->assertEquals( '', Xml::expandAttributes( [] ),
+ $this->assertSame( '', Xml::expandAttributes( [] ),
'Converting an empty list of attributes'
);
}
$recentChange2 = $this->getEditChange( '20131103092253' );
$html = $enhancedChangesList->recentChangesLine( $recentChange2, false );
- $this->assertEquals( '', $html );
+ $this->assertSame( '', $html );
}
public function testRecentChangesPrefix() {
$content = null;
$text = ContentHandler::getContentText( $content );
- $this->assertEquals( '', $text );
+ $this->assertSame( '', $text );
}
public static function dataGetContentText_TextContent() {
$content = $handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
- $this->assertEquals( '', $content->getData() );
+ $this->assertSame( '', $content->getData() );
}
public static function dataIsSupportedFormat() {
public function testGetWikitextForTransclusion() {
$content = $this->newContent( 'hello world.' );
- $this->assertEquals( '', $content->getWikitextForTransclusion() );
+ $this->assertFalse( $content->getWikitextForTransclusion() );
}
/**
$content = $this->handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
- $this->assertEquals( '', $content->getText() );
+ $this->assertSame( '', $content->getText() );
}
public static function dataIsSupportedFormat() {
/** @var IMaintainableDatabase $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
- $this->assertEquals(
+ $this->assertSame(
'',
$db->getDomainId(),
'Null domain ID handle used'
);
- $this->assertEquals(
- '',
+ $this->assertNull(
$db->getDBname(),
'Null domain ID handle used'
);
- $this->assertEquals(
+ $this->assertSame(
'',
$db->tablePrefix(),
'Main domain ID handle used; prefix is empty though'
/** @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' ),
* @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->hideDeprecated( 'Http::getProxy' );
$this->setMwGlobals( 'wgHTTPProxy', false );
- $this->assertEquals(
+ $this->assertSame(
'',
Http::getProxy(),
'default setting'
$linkRenderer = new LinkRenderer( $titleFormatter, $linkCache, $nsInfo );
$linkRenderer->setStubThreshold( 0 );
- $this->assertEquals(
+ $this->assertSame(
'',
$linkRenderer->getLinkClasses( $foobarTitle )
);
);
$linkRenderer->setStubThreshold( 20 );
- $this->assertEquals(
+ $this->assertSame(
'',
$linkRenderer->getLinkClasses( $userTitle )
);
] );
$context = $this->getResourceLoaderContext( [], $rl );
- $this->assertEquals(
+ $this->assertSame(
'',
$rl->getCombinedVersion( $context, [] ),
'empty list'
$path = '//acme.com/'; // protocol-relative URL
$site->setPath( $type, $path );
- $this->assertEquals( '', $site->getProtocol() );
+ $this->assertSame( '', $site->getProtocol() );
}
public static function provideGetPageUrl() {
$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' ] ) );
// 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(
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' ],