From 899c5d7cd523f12410f9056758b8e95e8b6bb93d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20G=C3=BCnther?= Date: Mon, 13 Aug 2012 16:46:12 +0200 Subject: [PATCH] [FEATURE] Backend usergroup model and repository This patch delivers an backend usergroup model and repository. Change-Id: Ie0da23ee0160a928f74726ceec5b243348a331ef Resolves: #39332 Releases: 6.0 Reviewed-on: http://review.typo3.org/13626 Reviewed-by: Mattias Nilsson Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn --- .../Classes/Domain/Model/BackendUserGroup.php | 588 +++++++++++++++ .../Repository/BackendUserGroupRepository.php | 50 ++ .../Domain/Model/BackendUserGroupTest.php | 675 ++++++++++++++++++ .../BackendUserGroupRepositoryTest.php | 71 ++ typo3/sysext/extbase/ext_typoscript_setup.txt | 21 + 5 files changed, 1405 insertions(+) create mode 100644 typo3/sysext/extbase/Classes/Domain/Model/BackendUserGroup.php create mode 100644 typo3/sysext/extbase/Classes/Domain/Repository/BackendUserGroupRepository.php create mode 100644 typo3/sysext/extbase/Tests/Unit/Domain/Model/BackendUserGroupTest.php create mode 100644 typo3/sysext/extbase/Tests/Unit/Domain/Repository/BackendUserGroupRepositoryTest.php diff --git a/typo3/sysext/extbase/Classes/Domain/Model/BackendUserGroup.php b/typo3/sysext/extbase/Classes/Domain/Model/BackendUserGroup.php new file mode 100644 index 000000000000..fc5f8003e9dc --- /dev/null +++ b/typo3/sysext/extbase/Classes/Domain/Model/BackendUserGroup.php @@ -0,0 +1,588 @@ + + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * A copy is found in the textfile GPL.txt and important notices to the license + * from the author is found in LICENSE.txt distributed with these scripts. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * This model represents a backend usergroup. + * + * @author Markus Günther + * + * @package Extbase + * @subpackage Domain\Model + * + * @scope prototype + * @entity + * @api + */ +class Tx_Extbase_Domain_Model_BackendUserGroup extends Tx_Extbase_DomainObject_AbstractEntity { + + const FILE_OPPERATIONS = 1; + const FILE_UNZIP = 2; + const DIRECTORY_OPPERATIONS = 4; + const DIRECTORY_COPY = 8; + const DIRECTORY_REMOVE_RECURSIVELY = 16; + + /** + * @var string + * @validate notEmpty + */ + protected $title = ''; + + /** + * @var string + */ + protected $description = ''; + + /** + * @var Tx_Extbase_Persistence_ObjectStorage + */ + protected $subGroups; + + /** + * @var string + */ + protected $modules = ''; + + /** + * @var string + */ + protected $tablesListening = ''; + + /** + * @var string + */ + protected $tablesModify = ''; + + /** + * @var string + */ + protected $pageTypes = ''; + + /** + * @var string + */ + protected $allowedExcludeFields = ''; + + /** + * @var string + */ + protected $explicitlyAllowAndDeny = ''; + + /** + * @var string + */ + protected $allowedLanguages = ''; + + /** + * @var boolean + */ + protected $workspacePermission = FALSE; + + /** + * @var string + */ + protected $databaseMounts = ''; + + /** + * @var integer + */ + protected $fileOperationPermissions = 0; + + /** + * @var string + */ + protected $lockToDomain = ''; + + /** + * @var boolean + */ + protected $hideInList = FALSE; + + /** + * @var string + */ + protected $tsConfig = ''; + + /** + * Constructs this backend usergroup + */ + public function __construct() { + $this->subGroups = new Tx_Extbase_Persistence_ObjectStorage(); + } + + /** + * Setter for title + * + * @param string $title + * @return void + */ + public function setTitle($title) { + $this->title = $title; + } + + /** + * Getter for title + * + * @return string + */ + public function getTitle() { + return $this->title; + } + + /** + * Setter for description + * + * @param string $description + * @return void + */ + public function setDescription($description) { + $this->description = $description; + } + + /** + * Getter for description + * + * @return string + */ + public function getDescription() { + return $this->description; + } + + /** + * Setter for the sub groups + * + * @param Tx_Extbase_Persistence_ObjectStorage $subGroups + * @return void + */ + public function setSubGroups(Tx_Extbase_Persistence_ObjectStorage $subGroups) { + $this->subGroups = $subGroups; + } + + /** + * Adds a sub group to this backend user group + * + * @param Tx_Extbase_Domain_Model_BackendUserGroup $beGroup + * @return void + */ + public function addSubGroup(Tx_Extbase_Domain_Model_BackendUserGroup $beGroup) { + $this->subGroups->attach($beGroup); + } + + /** + * Removes sub group from this backend user group + * + * @param Tx_Extbase_Domain_Model_BackendUserGroup $groupToDelete + * @return void + */ + public function removeSubGroup(Tx_Extbase_Domain_Model_BackendUserGroup $groupToDelete) { + $this->subGroups->detach($groupToDelete); + } + + /** + * Remove all sub groups from this backend user group + * + * @return void + */ + public function removeAllSubGroups() { + $subGroups = clone $this->subGroups; + $this->subGroups->removeAll($subGroups); + } + + /** + * Getter of sub groups + * + * @return Tx_Extbase_Persistence_ObjectStorage + */ + public function getSubGroups() { + return $this->subGroups; + } + + /** + * Setter for modules + * + * @param string $modules + * @return void + */ + public function setModules($modules) { + $this->modules = $modules; + } + + /** + * Getter for modules + * + * @return string + */ + public function getModules() { + return $this->modules; + } + + /** + * Setter for tables listening + * + * @param string $tablesListening + * @return void + */ + public function setTablesListening($tablesListening) { + $this->tablesListening = $tablesListening; + } + + /** + * Getter for tables listening + * + * @return string + */ + public function getTablesListening() { + return $this->tablesListening; + } + + /** + * Setter for tables modify + * + * @param string $tablesModify + * @return void + */ + public function setTablesModify($tablesModify) { + $this->tablesModify = $tablesModify; + } + + /** + * Getter for tables modify + * + * @return string + */ + public function getTablesModify() { + return $this->tablesModify; + } + + /** + * Setter for page types + * + * @param string $pageTypes + * @return void + */ + public function setPageTypes($pageTypes) { + $this->pageTypes = $pageTypes; + } + + /** + * Getter for page types + * + * @return string + */ + public function getPageTypes() { + return $this->pageTypes; + } + + /** + * Setter for allowed exclude fields + * + * @param string $allowedExcludeFields + * @return void + */ + public function setAllowedExcludeFields($allowedExcludeFields) { + $this->allowedExcludeFields = $allowedExcludeFields; + } + + /** + * Getter for allowed exclude fields + * + * @return string + */ + public function getAllowedExcludeFields() { + return $this->allowedExcludeFields; + } + + /** + * Setter for explicitly allow and deny + * + * @param string $explicitlyAllowAndDeny + * @return void + */ + public function setExplicitlyAllowAndDeny($explicitlyAllowAndDeny) { + $this->explicitlyAllowAndDeny = $explicitlyAllowAndDeny; + } + + /** + * Getter for explicitly allow and deny + * + * @return string + */ + public function getExplicitlyAllowAndDeny() { + return $this->explicitlyAllowAndDeny; + } + + /** + * Setter for allowed languages + * + * @param string $allowedLanguages + * @return void + */ + public function setAllowedLanguages($allowedLanguages) { + $this->allowedLanguages = $allowedLanguages; + } + + /** + * Getter for allowed languages + * + * @return string + */ + public function getAllowedLanguages() { + return $this->allowedLanguages; + } + + /** + * Setter for workspace permission + * + * @param boolean $workspacePermission + * @return void + */ + public function setWorkspacePermissions($workspacePermission) { + $this->workspacePermission = $workspacePermission; + } + + /** + * Getter for workspace permission + * + * @return boolean + */ + public function getWorkspacePermission() { + return $this->workspacePermission; + } + + /** + * Setter for database mounts + * + * @param string $databaseMounts + * @return void + */ + public function setDatabaseMounts($databaseMounts) { + $this->databaseMounts = $databaseMounts; + } + + /** + * Getter for database mounts + * + * @return string + */ + public function getDatabaseMounts() { + return $this->databaseMounts; + } + + /** + * Getter for file operation permissions + * + * @param integer $fileOperationPermissions + * @return void + */ + public function setFileOperationPermissions($fileOperationPermissions) { + $this->fileOperationPermissions = $fileOperationPermissions; + } + + /** + * Getter for file operation permissions + * + * @return integer + */ + public function getFileOperationPermissions() { + return $this->fileOperationPermissions; + } + + /** + * Check if file operations like upload, copy, move, delete, rename, new and + * edit files is allowed. + * + * @return boolean + */ + public function isFileOperationAllowed() { + return $this->isPermissionSet(self::FILE_OPPERATIONS); + } + + /** + * Set the the bit for file operations are allowed. + * + * @param boolean + * @return void + */ + public function setFileOperationAllowed($value) { + $this->setPermission(self::FILE_OPPERATIONS, $value); + } + + /** + * Check if it is allowed to unzip files. + * + * @return boolean + */ + public function isFileUnzipAllowed() { + return $this->isPermissionSet(self::FILE_UNZIP); + } + + /** + * Set the the bit for unzip files are allowed. + * + * @param boolean + * @return void + */ + public function setFileUnzipAllowed($value) { + $this->setPermission(self::FILE_UNZIP, $value); + } + + /** + * Check if folder operations like move, delete, rename, and new are allowed. + * + * @return boolean + */ + public function isDirectoryOperationAllowed() { + return $this->isPermissionSet(self::DIRECTORY_OPPERATIONS); + } + + /** + * Set the the bit for directory operations are allowed. + * + * @param boolean + * @return void + */ + public function setDirectoryOperationAllowed($value) { + $this->setPermission(self::DIRECTORY_OPPERATIONS, $value); + } + + /** + * Check if it is allowed to copy folders. + * + * @return boolean + */ + public function isDirectoryCopyAllowed() { + return $this->isPermissionSet(self::DIRECTORY_COPY); + } + + /** + * Set the the bit for copy directories. + * + * @param boolean + * @return void + */ + public function setDirectoryCopyAllowed($value) { + $this->setPermission(self::DIRECTORY_COPY, $value); + } + + /** + * Check if it is allowed to remove folders recursively. + * + * @return boolean + */ + public function isDirectoryRemoveRecursivelyAllowed() { + return $this->isPermissionSet(self::DIRECTORY_REMOVE_RECURSIVELY); + } + + /** + * Set the the bit for remove directories recursively. + * + * @param boolean + * @return void + */ + public function setDirectoryRemoveRecursivelyAllowed($value) { + $this->setPermission(self::DIRECTORY_REMOVE_RECURSIVELY, $value); + } + + /** + * Setter for lock to domain + * + * @param string $lockToDomain + * @return void + */ + public function setLockToDomain($lockToDomain) { + $this->lockToDomain = $lockToDomain; + } + + /** + * Getter for lock to domain + * @return string + */ + public function getLockToDomain() { + return $this->lockToDomain; + } + + /** + * Setter for hide in list + * + * @param boolean $hideInList + * @return void + */ + public function setHideInList($hideInList) { + $this->hideInList = $hideInList; + } + + /** + * Getter for hide in list + * + * @return boolean + */ + public function getHideInList() { + return $this->hideInList; + } + + /** + * Setter for ts config + * + * @param string $tsConfig + */ + public function setTsConfig($tsConfig) { + $this->tsConfig = $tsConfig; + } + + /** + * Getter for ts config + * + * @return string + */ + public function getTsConfig() { + return $this->tsConfig; + } + + /** + * Helper method for checking the permissions bitwise. + * + * @param integer $permission + * @return boolean + */ + protected function isPermissionSet($permission) { + return (($this->fileOperationPermissions & $permission) == $permission); + } + + /** + * Helper method for settung permissions bitwise. + * + * @param integer $permission + * @param boolean $value + * @return void + */ + protected function setPermission($permission, $value) { + if($value) { + $this->fileOperationPermissions |= $permission; + } else { + $this->fileOperationPermissions &= ~$permission; + } + } +} +?> diff --git a/typo3/sysext/extbase/Classes/Domain/Repository/BackendUserGroupRepository.php b/typo3/sysext/extbase/Classes/Domain/Repository/BackendUserGroupRepository.php new file mode 100644 index 000000000000..d0832188390f --- /dev/null +++ b/typo3/sysext/extbase/Classes/Domain/Repository/BackendUserGroupRepository.php @@ -0,0 +1,50 @@ + + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * A copy is found in the textfile GPL.txt and important notices to the license + * from the author is found in LICENSE.txt distributed with these scripts. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Repository for Tx_Extbase_Domain_Model_BackendUserGroup. + * + * @author Markus Günther + * + * @package Extbase + * @subpackage Domain\Repository + * @api + */ +class Tx_Extbase_Domain_Repository_BackendUserGroupRepository extends Tx_Extbase_Persistence_Repository { + + /** + * Initializes the repository. + * + * @return void + */ + public function initializeObject() { + /** @var $querySettings Tx_Extbase_Persistence_Typo3QuerySettings */ + $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_Typo3QuerySettings'); + $querySettings->setRespectStoragePage(FALSE); + $this->setDefaultQuerySettings($querySettings); + } +} +?> \ No newline at end of file diff --git a/typo3/sysext/extbase/Tests/Unit/Domain/Model/BackendUserGroupTest.php b/typo3/sysext/extbase/Tests/Unit/Domain/Model/BackendUserGroupTest.php new file mode 100644 index 000000000000..e171b1f49345 --- /dev/null +++ b/typo3/sysext/extbase/Tests/Unit/Domain/Model/BackendUserGroupTest.php @@ -0,0 +1,675 @@ + + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * A copy is found in the textfile GPL.txt and important notices to the license + * from the author is found in LICENSE.txt distributed with these scripts. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Testcase for Tx_Extbase_Domain_Model_BackendUserGroup. + * + * @author Markus Günther + * + * @package Extbase + * @subpackage Domain\Model + * + * @scope prototype + * @entity + * @api + */ +class Tx_Extbase_Tests_Unit_Domain_Model_BackendUserGroupTest extends Tx_Extbase_Tests_Unit_BaseTestCase { + + /** + * @var Tx_Extbase_Domain_Model_BackendUserGroup + */ + protected $fixture = NULL; + + public function setUp() { + $this->fixture = new Tx_Extbase_Domain_Model_BackendUserGroup(); + } + + public function tearDown() { + unset($this->fixture); + } + + /** + * @test + */ + public function getTitleInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getTitle() + ); + } + + /** + * @test + */ + public function setTitleSetsTitle() { + $title = 'foo bar'; + $this->fixture->setTitle($title); + + $this->assertSame( + $title, + $this->fixture->getTitle() + ); + } + + /** + * @test + */ + public function getDescriptionInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getDescription() + ); + } + + /** + * @test + */ + public function setDescriptionSetsDescription() { + $description = 'foo bar'; + $this->fixture->setDescription($description); + + $this->assertSame( + $description, + $this->fixture->getDescription() + ); + } + + /** + * @test + */ + public function setSubGroupsSetsSubgroups() { + $subGroups = new Tx_Extbase_Persistence_ObjectStorage(); + $this->fixture->setSubGroups($subGroups); + + $this->assertSame( + $subGroups, + $this->fixture->getSubGroups() + ); + } + + /** + * @test + */ + public function anSubGroupCanBeRemoved() { + $group1 = new Tx_Extbase_Domain_Model_BackendUserGroup; + $group1->setTitle('foo'); + $group2 = new Tx_Extbase_Domain_Model_BackendUserGroup; + $group2->setTitle('bar'); + + $this->fixture->addSubGroup($group1); + $this->fixture->addSubGroup($group2); + $this->assertEquals(count($this->fixture->getSubGroups()), 2); + $this->fixture->removeSubGroup($group1); + $this->assertEquals(count($this->fixture->getSubGroups()), 1); + $this->fixture->removeSubGroup($group2); + $this->assertEquals(count($this->fixture->getSubGroups()), 0); + } + + /** + * @test + */ + public function allSubGroupsCanBeRemoved() { + $group1 = new Tx_Extbase_Domain_Model_BackendUserGroup; + $group1->setTitle('foo'); + $group2 = new Tx_Extbase_Domain_Model_BackendUserGroup; + $group2->setTitle('bar'); + + $this->fixture->addSubGroup($group1); + $this->fixture->addSubGroup($group2); + $this->fixture->removeAllSubGroups(); + + $this->assertEquals(count($this->fixture->getSubGroups()), 0); + } + + /** + * @test + */ + public function getModulesInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getModules() + ); + } + + /** + * @test + */ + public function setModulesSetsModules() { + $modules = 'foo,bar'; + $this->fixture->setModules($modules); + + $this->assertSame( + $modules, + $this->fixture->getModules() + ); + } + + /** + * @test + */ + public function getTablesListeningInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getTablesListening() + ); + } + + /** + * @test + */ + public function setTablesListeningSetsTablesListening() { + $tablesListening = 'foo,bar'; + $this->fixture->setTablesListening($tablesListening); + + $this->assertSame( + $tablesListening, + $this->fixture->getTablesListening() + ); + } + + /** + * @test + */ + public function getTablesModifyInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getTablesModify() + ); + } + + /** + * @test + */ + public function getPageTypesInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getPageTypes() + ); + } + + /** + * @test + */ + public function setPageTypesSetsPageTypes() { + $pageTypes = 'foo,bar'; + $this->fixture->setPageTypes($pageTypes); + + $this->assertSame( + $pageTypes, + $this->fixture->getPageTypes() + ); + } + + /** + * @test + */ + public function setTablesModifySetsTablesModify() { + $tablesModify = 'foo,bar'; + $this->fixture->setTablesModify($tablesModify); + + $this->assertSame( + $tablesModify, + $this->fixture->getTablesModify() + ); + } + + /** + * @test + */ + public function getAllowedExcludeFieldsInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getAllowedExcludeFields() + ); + } + + /** + * @test + */ + public function setAllowedExcludeFieldsSetsAllowedExcludeFields() { + $allowedExcludeFields = 'foo,bar'; + $this->fixture->setAllowedExcludeFields($allowedExcludeFields); + + $this->assertSame( + $allowedExcludeFields, + $this->fixture->getAllowedExcludeFields() + ); + } + + /** + * @test + */ + public function getExplicitlyAllowAndDenyInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getExplicitlyAllowAndDeny() + ); + } + + /** + * @test + */ + public function setExplicitlyAllowAndDenySetsExplicitlyAllowAndDeny() { + $explicitlyAllowAndDeny = 'foo,bar'; + $this->fixture->setExplicitlyAllowAndDeny($explicitlyAllowAndDeny); + + $this->assertSame( + $explicitlyAllowAndDeny, + $this->fixture->getExplicitlyAllowAndDeny() + ); + } + + /** + * @test + */ + public function getAllowedLanguagesInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getAllowedLanguages() + ); + } + + /** + * @test + */ + public function setAllowedLanguagesSetsAllowedLanguages() { + $allowedLanguages = '1,0'; + $this->fixture->setAllowedLanguages($allowedLanguages); + + $this->assertSame( + $allowedLanguages, + $this->fixture->getAllowedLanguages() + ); + } + + /** + * @test + */ + public function getWorkspacePermissionInitiallyReturnsFalse() { + $this->assertFalse( + $this->fixture->getWorkspacePermission() + ); + } + + /** + * @test + */ + public function setWorkspacePermissionSetsWorkspacePermission() { + $this->fixture->setWorkspacePermissions(TRUE); + + $this->assertTrue( + $this->fixture->getWorkspacePermission() + ); + } + + /** + * @test + */ + public function getDatabaseMountsInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getDatabaseMounts() + ); + } + + /** + * @test + */ + public function setDatabaseMountsSetsDatabaseMounts() { + $mounts = '1,42'; + $this->fixture->setDatabaseMounts($mounts); + + $this->assertSame( + $mounts, + $this->fixture->getDatabaseMounts() + ); + } + + /** + * @test + */ + public function getFileOperationPermissionsInitiallyReturnsZero() { + $this->assertSame( + 0, + $this->fixture->getFileOperationPermissions() + ); + } + + /** + * @test + */ + public function setFileOperationPermissionsSetsFileOperationPermissions() { + $permission = 7; + $this->fixture->setFileOperationPermissions($permission); + + $this->assertSame( + $permission, + $this->fixture->getFileOperationPermissions() + ); + } + + /** + * @test + */ + public function getIsFileOperationAllowedReturnsFalse() { + $this->fixture->setFileOperationPermissions(0); + $this->assertFalse( + $this->fixture->isFileOperationAllowed() + ); + + $this->fixture->setFileOperationPermissions(2); + $this->assertFalse( + $this->fixture->isFileOperationAllowed() + ); + + $this->fixture->setFileOperationPermissions(6); + $this->assertFalse( + $this->fixture->isFileOperationAllowed() + ); + } + + /** + * @test + */ + public function getIsFileOperationAllowedReturnsTrue() { + $this->fixture->setFileOperationPermissions(1); + $this->assertTrue( + $this->fixture->isFileOperationAllowed() + ); + + $this->fixture->setFileOperationPermissions(3); + $this->assertTrue( + $this->fixture->isFileOperationAllowed() + ); + } + + /** + * @test + */ + public function setFileOperationAllowedSetsFileOperationAllowed() { + $this->fixture->setFileOperationPermissions(0); + $this->fixture->setFileOperationAllowed(TRUE); + + $this->assertTrue( + $this->fixture->isFileOperationAllowed() + ); + } + + /** + * @test + */ + public function getIsFileUnzipAllowedReturnsFalse() { + $this->fixture->setFileOperationPermissions(0); + $this->assertFalse( + $this->fixture->isFileUnzipAllowed() + ); + + $this->fixture->setFileOperationPermissions(1); + $this->assertFalse( + $this->fixture->isFileUnzipAllowed() + ); + + $this->fixture->setFileOperationPermissions(5); + $this->assertFalse( + $this->fixture->isFileUnzipAllowed() + ); + } + + /** + * @test + */ + public function getIsFileUnzipAllowedReturnsTrue() { + $this->fixture->setFileOperationPermissions(2); + $this->assertTrue( + $this->fixture->isFileUnzipAllowed() + ); + + $this->fixture->setFileOperationPermissions(3); + $this->assertTrue( + $this->fixture->isFileUnzipAllowed() + ); + } + + /** + * @test + */ + public function setFileUnzipAllowedSetsFileUnzipAllowed() { + $this->fixture->setFileOperationPermissions(0); + $this->fixture->setFileUnzipAllowed(TRUE); + + $this->assertTrue( + $this->fixture->isFileUnzipAllowed() + ); + } + + /** + * @test + */ + public function getIsDirectoryRemoveRecursivelyAllowedReturnsFalse() { + $this->fixture->setFileOperationPermissions(1); + $this->assertFalse( + $this->fixture->isDirectoryRemoveRecursivelyAllowed() + ); + + $this->fixture->setFileOperationPermissions(15); + $this->assertFalse( + $this->fixture->isDirectoryRemoveRecursivelyAllowed() + ); + + $this->fixture->setFileOperationPermissions(7); + $this->assertFalse( + $this->fixture->isDirectoryRemoveRecursivelyAllowed() + ); + } + + /** + * @test + */ + public function getIsDirectoryRemoveRecursivelyAllowedReturnsTrue() { + $this->fixture->setFileOperationPermissions(16); + $this->assertTrue( + $this->fixture->isDirectoryRemoveRecursivelyAllowed() + ); + + $this->fixture->setFileOperationPermissions(31); + $this->assertTrue( + $this->fixture->isDirectoryRemoveRecursivelyAllowed() + ); + } + + /** + * @test + */ + public function setDirectoryRemoveRecursivelyAllowedSetsDirectoryRemoveRecursivelyAllowed() { + $this->fixture->setFileOperationPermissions(0); + $this->fixture->setDirectoryRemoveRecursivelyAllowed(TRUE); + + $this->assertTrue( + $this->fixture->isDirectoryRemoveRecursivelyAllowed() + ); + } + + /** + * @test + */ + public function getIsDirectoryCopyAllowedReturnsFalse() { + $this->fixture->setFileOperationPermissions(0); + $this->assertFalse( + $this->fixture->isDirectoryCopyAllowed() + ); + + $this->fixture->setFileOperationPermissions(7); + $this->assertFalse( + $this->fixture->isDirectoryCopyAllowed() + ); + + $this->fixture->setFileOperationPermissions(23); + $this->assertFalse( + $this->fixture->isDirectoryCopyAllowed() + ); + } + + /** + * @test + */ + public function getIsDirectoryCopyAllowedReturnsTrue() { + $this->fixture->setFileOperationPermissions(8); + $this->assertTrue( + $this->fixture->isDirectoryCopyAllowed() + ); + + $this->fixture->setFileOperationPermissions(15); + $this->assertTrue( + $this->fixture->isDirectoryCopyAllowed() + ); + } + + /** + * @test + */ + public function setDirectoryCopyAllowedSetsDirectoryCopyAllowed() { + $this->fixture->setFileOperationPermissions(0); + $this->fixture->setDirectoryCopyAllowed(TRUE); + + $this->assertTrue( + $this->fixture->isDirectoryCopyAllowed() + ); + } + + /** + * @test + */ + public function getIsDirectoryOperationAllowedReturnsFalse() { + $this->fixture->setFileOperationPermissions(0); + $this->assertFalse( + $this->fixture->isDirectoryOperationAllowed() + ); + + $this->fixture->setFileOperationPermissions(3); + $this->assertFalse( + $this->fixture->isDirectoryOperationAllowed() + ); + + $this->fixture->setFileOperationPermissions(11); + $this->assertFalse( + $this->fixture->isDirectoryOperationAllowed() + ); + } + + /** + * @test + */ + public function getIsDirectoryOperationAllowedReturnsTrue() { + $this->fixture->setFileOperationPermissions(4); + $this->assertTrue( + $this->fixture->isDirectoryOperationAllowed() + ); + + $this->fixture->setFileOperationPermissions(7); + $this->assertTrue( + $this->fixture->isDirectoryOperationAllowed() + ); + } + + /** + * @test + */ + public function setDirectoryOperationAllowedSetsDirectoryOperationAllowed() { + $this->fixture->setFileOperationPermissions(0); + $this->fixture->setDirectoryoperationAllowed(TRUE); + + $this->assertTrue( + $this->fixture->isDirectoryOperationAllowed() + ); + } + + /** + * @test + */ + public function getLockToDomainInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getLockToDomain() + ); + } + + /** + * @test + */ + public function setLockToDomainSetsLockToDomain() { + $lockToDomain = 'foo.bar'; + $this->fixture->setLockToDomain($lockToDomain); + + $this->assertSame( + $lockToDomain, + $this->fixture->getLockToDomain() + ); + } + + /** + * @test + */ + public function getHideInListInitiallyReturnsFalse() { + $this->assertFalse( + $this->fixture->getHideInList() + ); + } + + /** + * @test + */ + public function setHideInListSetsHideInList() { + $this->fixture->setHideInList(TRUE); + + $this->assertTrue( + $this->fixture->getHideInList() + ); + } + + /** + * @test + */ + public function getTsConfigInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getTsConfig() + ); + } + + /** + * @test + */ + public function setTsConfigSetsTsConfig() { + $tsConfig = 'foo bar'; + $this->fixture->setTsConfig($tsConfig); + + $this->assertSame( + $tsConfig, + $this->fixture->getTsConfig() + ); + } +} +?> \ No newline at end of file diff --git a/typo3/sysext/extbase/Tests/Unit/Domain/Repository/BackendUserGroupRepositoryTest.php b/typo3/sysext/extbase/Tests/Unit/Domain/Repository/BackendUserGroupRepositoryTest.php new file mode 100644 index 000000000000..a0aa288aff21 --- /dev/null +++ b/typo3/sysext/extbase/Tests/Unit/Domain/Repository/BackendUserGroupRepositoryTest.php @@ -0,0 +1,71 @@ + + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Testcase for Tx_Extbase_Domain_Repository_BackendUserRepository. + * + * @author Markus Günther + * + * @package Extbase + * @subpackage Domain\Repository + * @api + */ +class Tx_Extbase_Tests_Unit_Domain_Repository_BackendUserGroupRepositoryTest extends Tx_Extbase_Tests_Unit_BaseTestCase { + + /** + * @test + */ + public function initializeObjectSetsRespectStoragePidToFalse() { + $objectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface'); + $fixture = new Tx_Extbase_Domain_Repository_BackendUserGroupRepository($objectManager); + + $querySettings = $this->getMock('Tx_Extbase_Persistence_Typo3QuerySettings'); + $querySettings->expects($this->once())->method('setRespectStoragePage')->with(FALSE); + $objectManager->expects($this->once())->method('create') + ->with('Tx_Extbase_Persistence_Typo3QuerySettings')->will($this->returnValue($querySettings)); + + $fixture->initializeObject(); + } + + /** + * @test + */ + public function initializeObjectSetsDefaultQuerySettings() { + $objectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface'); + /** @var $fixture Tx_Extbase_Domain_Repository_BackendUserGroupRepository */ + $fixture = $this->getMock( + 'Tx_Extbase_Domain_Repository_BackendUserGroupRepository', + array('setDefaultQuerySettings'), array($objectManager) + ); + + $querySettings = $this->getMock('Tx_Extbase_Persistence_Typo3QuerySettings'); + $objectManager->expects($this->once())->method('create') + ->with('Tx_Extbase_Persistence_Typo3QuerySettings')->will($this->returnValue($querySettings)); + + $fixture->expects($this->once())->method('setDefaultQuerySettings')->with($querySettings); + + $fixture->initializeObject(); + } +} +?> \ No newline at end of file diff --git a/typo3/sysext/extbase/ext_typoscript_setup.txt b/typo3/sysext/extbase/ext_typoscript_setup.txt index f3c181b52807..057f523a987a 100644 --- a/typo3/sysext/extbase/ext_typoscript_setup.txt +++ b/typo3/sysext/extbase/ext_typoscript_setup.txt @@ -44,6 +44,27 @@ config.tx_extbase { } } } + Tx_Extbase_Domain_Model_BackendUserGroup { + mapping { + tableName = be_groups + columns { + subgroup.mapOnProperty = subGroups + groupMods.mapOnProperty = modules + tables_select.mapOnProperty = tablesListening + tables_modify.mapOnProperty = tablesModify + pagetypes_select.mapOnProperty = pageTypes + non_exclude_fields.mapOnProperty = allowedExcludeFields + explicit_allowdeny.mapOnProperty = explicitlyAllowAndDeny + allowed_languages.mapOnProperty = allowedLanguages + workspace_perms.mapOnProperty = workspacePermission + db_mountpoints.mapOnProperty = databaseMounts + fileoper_perms.mapOnProperty = fileOperationPermissions + lockToDomain.mapOnProperty = lockToDomain + hide_in_lists.mapOnProperty = hideInList + TSconfig.mapOnProperty = tsConfig + } + } + } Tx_Extbase_Domain_Model_FrontendUser { mapping { tableName = fe_users -- 2.20.1