Index: typo3/tests/t3lib_tcemain_testcase.php =================================================================== --- typo3/tests/t3lib_tcemain_testcase.php (revision 0) +++ typo3/tests/t3lib_tcemain_testcase.php (revision 0) @@ -0,0 +1,155 @@ + + */ +class t3lib_tcemain_testcase extends tx_phpunit_testcase { + /** + * @var t3lib_TCEmain + */ + private $fixture; + + /** + * @var t3lib_beUserAuth a simulated logged-in back-end user + */ + private $backEndUser; + + public function setUp() { + $this->backEndUser = $this->createBackEndUser(); + + $this->fixture = new t3lib_TCEmain(); + $this->fixture->start(array(), '', $this->backEndUser); + } + + public function tearDown() { + unset( + $this->fixture->BE_USER, $this->fixture, $this->backEndUser + ); + } + + + ////////////////////// + // Utility functions + ////////////////////// + + /** + * Creates a back-end user. + * + * @return t3lib_beUserAuth a back-end user + */ + private function createBackEndUser() { + $user = new t3lib_beUserAuth(); + $user->user = array(); + + return $user; + } + + + //////////////////////////////////// + // Tests for the utility functions + //////////////////////////////////// + + public function testCreateBackEndUserCreatesBeUserAuthInstance() { + $this->assertTrue( + $this->createBackEndUser() instanceof t3lib_beUserAuth + ); + } + + + ////////////////////////////////////// + // Tests for the basic functionality + ////////////////////////////////////// + + public function testFixtureCanBeCreated() { + $this->assertTrue( + $this->fixture instanceof t3lib_TCEmain + ); + } + + + ////////////////////////////////////////// + // Test concerning checkModifyAccessList + ////////////////////////////////////////// + + public function testCheckModifyAccessListForAdminForContentTableReturnsTrue() { + $this->fixture->admin = true; + + $this->assertTrue( + $this->fixture->checkModifyAccessList('tt_content') + ); + } + + public function testCheckModifyAccessListForNonAdminForContentTableReturnsFalse() { + $this->fixture->admin = false; + + $this->assertFalse( + $this->fixture->checkModifyAccessList('tt_content') + ); + } + + public function testCheckModifyAccessListForNonAdminWithTableModifyAccessForContentTableReturnsTrue() { + $this->fixture->admin = false; + $this->backEndUser->groupData['tables_modify'] = 'tt_content'; + + $this->assertTrue( + $this->fixture->checkModifyAccessList('tt_content') + ); + } + + public function testCheckModifyAccessListForAdminForBeUsersTableReturnsTrue() { + $this->fixture->admin = true; + + $this->assertTrue( + $this->fixture->checkModifyAccessList('be_users') + ); + } + + public function testCheckModifyAccessListForNonAdminForBeUsersTableReturnsFalse() { + $this->fixture->admin = false; + + $this->assertFalse( + $this->fixture->checkModifyAccessList('be_users') + ); + } + + public function testCheckModifyAccessListForNonAdminWithTableModifyAccessForBeUsersTableReturnsFalse() { + $this->fixture->admin = false; + $this->backEndUser->groupData['tables_modify'] = 'be_users'; + + $this->assertFalse( + $this->fixture->checkModifyAccessList('be_users') + ); + } +} +?>\ No newline at end of file