public function testResolveAccessCanCurrentUserWriteModule() { $betty = User::getByUsername('betty'); Yii::app()->user->userModel = $betty; TestHelpers::createControllerAndModuleByRoute('accounts/default'); $this->startOutputBuffer(); try { ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModule('Accounts', true); $this->endPrintOutputBufferAndFail(); } catch (ExitException $e) { $content = $this->endAndGetOutputBuffer(); $this->assertEquals('failure', $content); } $this->startOutputBuffer(); try { ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModule('Accounts', false); $this->endPrintOutputBufferAndFail(); } catch (ExitException $e) { $compareString = 'You have tried to access a page you do not have access to'; $this->assertContains($compareString, $this->endAndGetOutputBuffer()); } $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; TestHelpers::createControllerAndModuleByRoute('accounts/default'); $this->startOutputBuffer(); try { ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModule('Accounts', true); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModule('Accounts', false); $content = $this->endAndGetOutputBuffer(); $this->assertEquals(null, $content); } catch (ExitException $e) { $this->endPrintOutputBufferAndFail(); } }