Commit ec41f219 authored by Sebastian Seidelmann's avatar Sebastian Seidelmann Committed by Christian Kuhn
Browse files

[BUGFIX] Correct calculation of pageIsNotLockedForEditors

Resolves the wrong calculation of binary operator result
that is used to check if the edit page button in page module
is displayed or not.

Resolves: #71363
Releases: master
Change-Id: I83f46e267d3716ef3954bd1470fa5fe01a9bc17f
Reviewed-on: https://review.typo3.org/44568

Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent a3e3a616
......@@ -1347,7 +1347,7 @@ class PageLayoutController
*/
public function pageIsNotLockedForEditors()
{
return $this->getBackendUser()->isAdmin() || !($this->CALC_PERMS & Permission::PAGE_EDIT && $this->pageinfo['editlock']);
return $this->getBackendUser()->isAdmin() || ($this->CALC_PERMS & Permission::PAGE_EDIT) === Permission::PAGE_EDIT && !$this->pageinfo['editlock'];
}
/**
......
<?php
namespace TYPO3\CMS\Backend\Tests\Unit\Controller;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Controller\PageLayoutController;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Tests\UnitTestCase;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
/**
* Class PageLayoutControllerTest
*/
class PageLayoutControllerTest extends UnitTestCase
{
/**
* @test
* @dataProvider pageIsNotLockedForEditorsReturnsCorrectValueDataProvider
* @param bool $isAdmin
* @param int $permissions
* @param bool $editLock
* @param bool $expected
*/
public function pageIsNotLockedForEditorsReturnsCorrectValue($isAdmin, $permissions, $editLock, $expected)
{
/** @var BackendUserAuthentication|\PHPUnit_Framework_MockObject_MockObject $beUserMock */
$beUserMock = $this->getMock(BackendUserAuthentication::class, ['isAdmin']);
$beUserMock->method('isAdmin')->will($this->returnValue($isAdmin));
/** @var PageLayoutController|\PHPUnit_Framework_MockObject_MockObject $pageController */
$pageController = $this->getMock(PageLayoutController::class, ['getBackendUser']);
$pageController->method('getBackendUser')->will($this->returnValue($beUserMock));
$pageController->CALC_PERMS = $permissions;
$pageController->pageinfo = ['editlock' => $editLock];
$this->assertTrue($pageController->pageIsNotLockedForEditors() === $expected);
}
/**
* @return array
*/
public function pageIsNotLockedForEditorsReturnsCorrectValueDataProvider()
{
return [
'user is admin' => [ true, 0, false, true],
'user has permission' => [ false, Permission::PAGE_EDIT, false, true],
'page has permission, but editlock set' => [ false, Permission::PAGE_EDIT, true, false],
'user does not have permission' => [ false, 0, false, false],
];
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment