mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-27 17:00:37 +00:00
Replace all loose assertEquals with strict PHPUnit assertions
A method that is expected to return, for example, a boolean true should not return an other value that PHPs loose == comparison might also consider true. Same for all other loose equality checks. Change-Id: If729c6e97d5337eee10b717da76dad428218ff69
This commit is contained in:
parent
33a96c7ab2
commit
3eb7c9b976
|
@ -67,7 +67,7 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
public function testShowPreviewsPreferencesPage( array $config, $expected ) {
|
||||
$this->setMwGlobals( $config );
|
||||
$context = $this->getContext();
|
||||
$this->assertEquals( $expected,
|
||||
$this->assertSame( $expected,
|
||||
$context->showPreviewsOptInOnPreferencesPage(),
|
||||
'The previews opt-in is ' . ( $expected ? 'shown.' : 'hidden.' ) );
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
$context = $this->getContext();
|
||||
$user = $this->getMutableTestUser()->getUser();
|
||||
$user->setOption( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME, $optIn );
|
||||
$this->assertEquals( $expected,
|
||||
$this->assertSame( $expected,
|
||||
$context->shouldSendModuleToUser( $user ),
|
||||
( $expected ? 'A' : 'No' ) . ' module is sent to the user.' );
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
PopupsContext::PREVIEWS_DISABLED );
|
||||
|
||||
$context = $this->getContext();
|
||||
$this->assertEquals( $expected,
|
||||
$this->assertSame( $expected,
|
||||
$context->shouldSendModuleToUser( $user ),
|
||||
( $expected ? 'A' : 'No' ) . ' module is sent to the user.' );
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
->method( 'isLoaded' )
|
||||
->will( new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls( $returnValues ) );
|
||||
$context = $this->getContext( $mock );
|
||||
$this->assertEquals( $expected,
|
||||
$this->assertSame( $expected,
|
||||
$context->areDependenciesMet(),
|
||||
'Dependencies are ' . ( $expected ? '' : 'not ' ) . 'met.' );
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
public function testIsTitleBlacklisted( array $blacklist, Title $title, $expected ) {
|
||||
$this->setMwGlobals( [ 'wgPopupsPageBlacklist' => $blacklist ] );
|
||||
$context = $this->getContext();
|
||||
$this->assertEquals( $expected,
|
||||
$this->assertSame( $expected,
|
||||
$context->isTitleBlacklisted( $title ),
|
||||
'The title is' . ( $expected ? ' ' : ' not ' ) . 'blacklisted.' );
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
'wgLanguageCode' => 'pl'
|
||||
] );
|
||||
$context = $this->getContext();
|
||||
$this->assertEquals( true,
|
||||
$this->assertTrue(
|
||||
$context->isTitleBlacklisted( Title::newFromText( $page ) ),
|
||||
'The title is blacklisted.' );
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
->willReturn( true );
|
||||
|
||||
$context = $this->getContext( null, $integrationMock );
|
||||
$this->assertEquals( true,
|
||||
$this->assertTrue(
|
||||
$context->conflictsWithNavPopupsGadget( $user ),
|
||||
'A conflict is identified.' );
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class PopupsGadgetsIntegrationTest extends MediaWikiTestCase {
|
|||
$user = $this->getTestUser()->getUser();
|
||||
$integration = new PopupsGadgetsIntegration( $this->getConfigMock(),
|
||||
$this->getExtensionRegistryMock( false ) );
|
||||
$this->assertEquals( false,
|
||||
$this->assertFalse(
|
||||
$integration->conflictsWithNavPopupsGadget( $user ),
|
||||
'No conflict is identified.' );
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ class PopupsGadgetsIntegrationTest extends MediaWikiTestCase {
|
|||
|
||||
$integration = new PopupsGadgetsIntegration( $config,
|
||||
$this->getExtensionRegistryMock( true ) );
|
||||
$this->assertEquals( $expected,
|
||||
$this->assertSame( $expected,
|
||||
$integration->conflictsWithNavPopupsGadget( $user ),
|
||||
( $expected ? 'A' : 'No' ) . ' conflict is identified.' );
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
|
||||
PopupsHooks::onGetPreferences( $this->getTestUser()->getUser(), $prefs );
|
||||
$this->assertCount( 1, $prefs, 'No preferences are retrieved.' );
|
||||
$this->assertEquals( 'notEmpty',
|
||||
$this->assertSame( 'notEmpty',
|
||||
$prefs[ 'someNotEmptyValue'],
|
||||
'No preferences are changed.' );
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
$this->assertArrayHasKey( 'disabled',
|
||||
$prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ],
|
||||
'The opt-in preference has a status.' );
|
||||
$this->assertEquals( true,
|
||||
$this->assertTrue(
|
||||
$prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME]['disabled'],
|
||||
'The opt-in preference\'s status is disabled.' );
|
||||
$this->assertNotEmpty( $prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME]['help-message'],
|
||||
|
@ -116,13 +116,13 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
|
||||
PopupsHooks::onGetPreferences( $this->getTestUser()->getUser(), $prefs );
|
||||
$this->assertCount( 4, $prefs, 'A preference is retrieved.' );
|
||||
$this->assertEquals( 'notEmpty',
|
||||
$this->assertSame( 'notEmpty',
|
||||
$prefs[ 'someNotEmptyValue'],
|
||||
'Unretrieved preferences are unchanged.' );
|
||||
$this->assertArrayHasKey( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
||||
$prefs,
|
||||
'The opt-in preference is retrieved.' );
|
||||
$this->assertEquals( 1,
|
||||
$this->assertSame( 1,
|
||||
array_search( \Popups\PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
||||
array_keys( $prefs ) ),
|
||||
'The opt-in preference is injected after Skin select.' );
|
||||
|
@ -155,7 +155,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
$this->assertArrayHasKey( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
||||
$prefs,
|
||||
'The opt-in preference is retrieved.' );
|
||||
$this->assertEquals( 2,
|
||||
$this->assertSame( 2,
|
||||
array_search( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
||||
array_keys( $prefs ) ),
|
||||
'The opt-in preference is appended.' );
|
||||
|
@ -178,7 +178,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
$this->assertCount( 6, $vars, 'A configuration is retrieved.' );
|
||||
|
||||
foreach ( $config as $key => $value ) {
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$vars[ $key ],
|
||||
"It forwards the \"{$key}\" config variable to the client."
|
||||
|
@ -322,7 +322,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
|
||||
PopupsHooks::onUserGetDefaultOptions( $userOptions );
|
||||
$this->assertCount( 2, $userOptions );
|
||||
$this->assertEquals( '1',
|
||||
$this->assertSame( '1',
|
||||
$userOptions[ \Popups\PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue