Skip to content

Commit

Permalink
Merge pull request #297 from malberts/issue-295
Browse files Browse the repository at this point in the history
Replace isLoggedIn()
  • Loading branch information
malberts committed Nov 6, 2021
2 parents 05de767 + 2bc1907 commit fbf0e91
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Components/NavbarHorizontal/PersonalTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function getNewtalkNotifier() {
return '';
}

$talkClass = $user->isLoggedIn() ? 'pt-mytalk' : 'pt-anontalk';
$talkClass = $user->isRegistered() ? 'pt-mytalk' : 'pt-anontalk';

$newtalkNotifier = $this->indent( 1 ) . '<span class="badge badge-pill badge-info ' .
$talkClass . '" title="' . $newMessagesAlert . '" href="#"></span>';
Expand All @@ -102,7 +102,7 @@ protected function getNewtalkNotifier() {
protected function getUserName() {
if ( filter_var( $this->getAttribute( self::ATTR_SHOW_USER_NAME ), FILTER_VALIDATE_BOOLEAN ) ) {
$user = $this->getSkinTemplate()->getSkin()->getUser();
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$username = !empty( $user->getRealName() ) ? $user->getRealName() : $user->getName();
return '<span class="user-name">' . htmlspecialchars( $username ) . '</span>';
}
Expand Down Expand Up @@ -187,7 +187,7 @@ protected function getEchoIcons() {
protected function getDropdownToggle(): string {
$user = $this->getSkinTemplate()->getSkin()->getUser();

if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {

$toolsClass = 'navbar-userloggedin';
$toolsLinkText = $this->getSkinTemplate()->getMsg( 'chameleon-loggedin' )->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PersonalToolsTest extends GenericComponentTestCase {
*/
public function testGetHtml_LoggedInUserHasNewMessages( $domElement ) {
$factory = MockupFactory::makeFactory( $this );
$factory->set( 'UserIsLoggedIn', true );
$factory->set( 'UserIsRegistered', true );
$chameleonTemplate = $factory->getChameleonSkinTemplateStub();
$chameleonTemplate->data = [ 'newtalk' => 'foo' ];

Expand All @@ -67,7 +67,7 @@ public function testGetHtml_LoggedInUserHasNewMessages( $domElement ) {
*/
public function testGetHtml_LoggedInUserHasNoNewMessages( $domElement ) {
$factory = MockupFactory::makeFactory( $this );
$factory->set( 'UserIsLoggedIn', true );
$factory->set( 'UserIsRegistered', true );
$chameleonTemplate = $factory->getChameleonSkinTemplateStub();
$chameleonTemplate->data = [ 'newtalk' => '' ];

Expand All @@ -83,7 +83,7 @@ public function testGetHtml_LoggedInUserHasNoNewMessages( $domElement ) {
*/
public function testGetHtml_LoggedOutUserHasNewMessages( $domElement ) {
$factory = MockupFactory::makeFactory( $this );
$factory->set( 'UserIsLoggedIn', false );
$factory->set( 'UserIsRegistered', false );
$chameleonTemplate = $factory->getChameleonSkinTemplateStub();
$chameleonTemplate->data = [ 'newtalk' => 'foo' ];

Expand All @@ -99,7 +99,7 @@ public function testGetHtml_LoggedOutUserHasNewMessages( $domElement ) {
*/
public function testGetHtml_LoggedOutUserHasNoNewMessages( $domElement ) {
$factory = MockupFactory::makeFactory( $this );
$factory->set( 'UserIsLoggedIn', false );
$factory->set( 'UserIsRegistered', false );
$chameleonTemplate = $factory->getChameleonSkinTemplateStub();
$chameleonTemplate->data = [ 'newtalk' => '' ];

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Util/MockupFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MockupFactory {

private $testCase;
private $configuration = [
'UserIsLoggedIn' => false,
'UserIsRegistered' => false,
'UserEffectiveGroups' => [ '*' ],
'UserRights' => [],
];
Expand Down Expand Up @@ -331,8 +331,8 @@ protected function getUserStub() {
->getMock();

$user->expects( $this->testCase->any() )
->method( 'isLoggedIn' )
->will( $this->testCase->returnValue( $this->get( 'UserIsLoggedIn', true ) ) );
->method( 'isRegistered' )
->will( $this->testCase->returnValue( $this->get( 'UserIsRegistered', true ) ) );

$user->expects( $this->testCase->any() )
->method( 'getEffectiveGroups' )
Expand Down

0 comments on commit fbf0e91

Please sign in to comment.