本文整理匯總了PHP中TYPO3\CMS\Core\FormProtection\FormProtectionFactory::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormProtectionFactory::set方法的具體用法?PHP FormProtectionFactory::set怎麽用?PHP FormProtectionFactory::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Core\FormProtection\FormProtectionFactory
的用法示例。
在下文中一共展示了FormProtectionFactory::set方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: logoffCleansFormProtection
/**
* @test
*/
public function logoffCleansFormProtection()
{
$formProtection = $this->getMock('TYPO3\\CMS\\Core\\FormProtection\\BackendFormProtection', array('clean'));
$formProtection->expects($this->atLeastOnce())->method('clean');
\TYPO3\CMS\Core\FormProtection\FormProtectionFactory::set('TYPO3\\CMS\\Core\\FormProtection\\BackendFormProtection', $formProtection);
$this->fixture->logoff();
}
示例2: logoffCleansFormProtectionIfBackendUserIsLoggedIn
/**
* @test
*/
public function logoffCleansFormProtectionIfBackendUserIsLoggedIn()
{
$formProtection = $this->getMock('TYPO3\\CMS\\Core\\FormProtection\\BackendFormProtection', array('clean'), array(), '', FALSE);
$formProtection->expects($this->once())->method('clean');
\TYPO3\CMS\Core\FormProtection\FormProtectionFactory::set('TYPO3\\CMS\\Core\\FormProtection\\BackendFormProtection', $formProtection);
// logoff() call the static factory that has a dependency to a valid BE_USER object. Mock this away
$GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(), array(), '', FALSE);
$GLOBALS['BE_USER']->user = array('uid' => uniqid());
$GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
$subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array('dummy'), array(), '', FALSE);
$subject->_set('db', $GLOBALS['TYPO3_DB']);
$subject->logoff();
}
示例3: logoffCleansFormProtectionIfBackendUserIsLoggedIn
/**
* @test
*/
public function logoffCleansFormProtectionIfBackendUserIsLoggedIn()
{
/** @var ObjectProphecy|Connection $connection */
$connection = $this->prophesize(Connection::class);
$connection->delete('be_sessions', Argument::cetera())->willReturn(1);
/** @var ObjectProphecy|ConnectionPool $connectionPool */
$connectionPool = $this->prophesize(ConnectionPool::class);
$connectionPool->getConnectionForTable(Argument::cetera())->willReturn($connection->reveal());
GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
/** @var ObjectProphecy|\TYPO3\CMS\Core\FormProtection\AbstractFormProtection $formProtection */
$formProtection = $this->prophesize(\TYPO3\CMS\Core\FormProtection\BackendFormProtection::class);
$formProtection->clean()->shouldBeCalled();
\TYPO3\CMS\Core\FormProtection\FormProtectionFactory::set('default', $formProtection->reveal());
// logoff() call the static factory that has a dependency to a valid BE_USER object. Mock this away
$GLOBALS['BE_USER'] = $this->getMock(BackendUserAuthentication::class, array(), array(), '', false);
$GLOBALS['BE_USER']->user = array('uid' => $this->getUniqueId());
$GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
$subject = $this->getAccessibleMock(BackendUserAuthentication::class, array('dummy'), array(), '', false);
$subject->_set('db', $GLOBALS['TYPO3_DB']);
$subject->logoff();
}
示例4: setNotSetsInstanceForOtherType
/**
* @test
*/
public function setNotSetsInstanceForOtherType()
{
$instance = new \TYPO3\CMS\Core\Tests\Unit\FormProtection\Fixtures\FormProtectionTesting();
\TYPO3\CMS\Core\FormProtection\FormProtectionFactory::set('TYPO3\\CMS\\Core\\FormProtection\\BackendFormProtection', $instance);
$this->assertNotSame($instance, \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get('TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection'));
}