本文整理汇总了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'));
}