本文整理汇总了PHP中CMTest_TH::clearCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::clearCache方法的具体用法?PHP CMTest_TH::clearCache怎么用?PHP CMTest_TH::clearCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMTest_TH
的用法示例。
在下文中一共展示了CMTest_TH::clearCache方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPrepare
public function testPrepare()
{
$actor = CMTest_TH::createUser();
$action = new CM_Action_Mock('foo', $actor);
$action->prepare(null);
CM_Db_Db::insert('cm_actionLimit', array('type' => 1, 'actionType' => 1, 'actionVerb' => 1, 'role' => null, 'limit' => 0, 'period' => 0));
CMTest_TH::clearCache();
try {
$action->prepare(null);
$this->fail('Limited action did not throw exception');
} catch (CM_Exception_ActionLimit $e) {
$this->assertSame('Mock overshoot', $e->getMessage());
}
}
示例2: testProcess
public function testProcess()
{
$replace = '…';
$badwords = new CM_Paging_ContentList_Badwords();
$filter = new CM_Usertext_Filter_Badwords();
$render = new CM_Frontend_Render();
$actual = $filter->transform("hello foo there", $render);
$this->assertSame("hello foo there", $actual);
$badwords->add('foo');
$badwords->add('x … x');
$badwords->add('f(o-].)o');
$badwords->add('bar');
$badwords->add('foobar');
$badwords->add('zoo*far');
CMTest_TH::clearCache();
$actual = $filter->transform("hello foo there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello x foo x there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello Foo there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello foot there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello f(o-].)o there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello bar there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello bart there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello bar3 there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello bartender there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello bar.de there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello bar. there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello foobar there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello XfoobarX there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello mayo.foobar.ran there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello zoofar there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello zoo!!far there", $render);
$this->assertSame("hello {$replace} there", $actual);
$actual = $filter->transform("hello zoo far there", $render);
$this->assertSame("hello {$replace} there", $actual);
}
示例3: testSetConversionStatic
public function testSetConversionStatic()
{
$request1 = $this->createRequest('/');
$request2 = $this->createRequest('/');
CM_Model_Splittest_RequestClient::setConversionStatic('foo', $request1);
$splittest = CM_Model_Splittest_RequestClient::create('foo', ['bar']);
/** @var CM_Model_SplittestVariation $variation */
$variation = $splittest->getVariations()->getItem(0);
$splittest->isVariationFixture($request1, 'bar');
$splittest->isVariationFixture($request2, 'bar');
$this->assertSame(0, $variation->getConversionCount());
CM_Model_Splittest_RequestClient::setConversionStatic('foo', $request1);
CMTest_TH::clearCache();
$this->assertSame(1, $variation->getConversionCount());
CM_Model_Splittest_RequestClient::setConversionStatic('foo', $request2, 2.5);
CMTest_TH::clearCache();
$this->assertSame(1.75, $variation->getConversionRate());
}
示例4: testGetUser
public function testGetUser()
{
$user = CM_Model_User::createStatic();
$user2 = CM_Model_User::createStatic();
CM_Model_Entity_Mock::createStatic(array('userId' => $user->getId(), 'foo' => 'bar1'));
$entityMock = new CM_Model_Entity_Mock(1);
$this->assertEquals($user->getId(), $entityMock->getUser()->getId());
$this->assertInstanceOf('CM_Model_User', $user);
$this->assertNotEquals($user2, $entityMock->getUser());
CM_Db_Db::delete('cm_user', array('userId' => $user->getId()));
CMTest_TH::clearCache();
try {
$entityMock->getUser();
$this->fail('User not deleted');
} catch (CM_Exception_Nonexistent $ex) {
$this->assertTrue(true);
}
$this->assertNull($entityMock->getUserIfExists());
}
示例5: testSetConversionStatic
public function testSetConversionStatic()
{
$user1 = CMTest_TH::createUser();
$user2 = CMTest_TH::createUser();
CM_Model_Splittest_User::setConversionStatic('foo', $user1);
$splittest = CM_Model_Splittest_User::create('foo', ['bar']);
/** @var CM_Model_SplittestVariation $variation */
$variation = $splittest->getVariations()->getItem(0);
$splittest->isVariationFixture($user1, 'bar');
$splittest->isVariationFixture($user2, 'bar');
$this->assertSame(0, $variation->getConversionCount());
CM_Model_Splittest_User::setConversionStatic('foo', $user1);
CMTest_TH::clearCache();
$this->assertSame(1, $variation->getConversionCount());
CM_Model_Splittest_User::setConversionStatic('foo', $user2, 2.5);
CMTest_TH::clearCache();
$this->assertSame(2, $variation->getConversionCount());
$this->assertSame(1.75, $variation->getConversionRate());
}
示例6: testGetVariationListSorted
public function testGetVariationListSorted()
{
/** @var CM_Model_Splittest $test */
$test = CM_Model_Splittest::create('foo', ['v1', 'v2']);
$variationList = $test->getVariationListSorted();
$this->assertSame('v1', $variationList[0]->getName());
$this->assertSame('v2', $variationList[1]->getName());
$request = new CM_Http_Request_Get('/');
CM_Model_Splittest_RequestClient::isVariationFixtureStatic('foo', $request, 'v1');
CM_Model_Splittest_RequestClient::setConversionStatic('foo', $request);
CMTest_TH::clearCache();
$variationList = $test->getVariationListSorted();
$this->assertTrue($variationList[0]->getConversionRate() > $variationList[1]->getConversionRate());
}
示例7: testStart
public function testStart()
{
/** @var CM_Model_User $user */
$user = CM_Model_User::createStatic();
$activityStamp1 = time();
$session = new CM_Session();
$session->setUser($user);
$sessionId = $session->getId();
unset($session);
$session = new CM_Session($sessionId);
$this->assertEquals($activityStamp1, $session->getUser(true)->getLatestActivity(), null, 1);
CMTest_TH::timeForward(CM_Model_User::ACTIVITY_EXPIRATION / 2);
$session = new CM_Session($sessionId);
$session->start();
$this->assertEquals($activityStamp1, $session->getUser(true)->getLatestActivity(), null, 1);
CM_Db_Db::update('cm_session', array('data' => serialize(array('userId' => $user->getId(), 'foo' => 'bar'))));
unset($session);
CMTest_TH::clearCache();
CMTest_TH::timeForward(CM_Model_User::ACTIVITY_EXPIRATION / 2 + 1);
$activityStamp2 = time();
$session = new CM_Session($sessionId);
$session->start();
$this->assertEquals($activityStamp2, $session->getUser(true)->getLatestActivity(), null, 1);
CMTest_TH::timeForward($session->getLifetime() / 2);
$session->start();
$this->assertEquals('bar', $session->get('foo'));
CM_Db_Db::update('cm_session', array('data' => serialize(array('userId' => $user->getId(), 'foo' => 'foo'))));
unset($session);
CMTest_TH::clearCache();
$session = new CM_Session($sessionId);
$this->assertEquals('bar', $session->get('foo'));
}
示例8: testGetEnabled
public function testGetEnabled()
{
/** @var CM_Model_Splitfeature $splitfeature */
$splitfeature = CM_Model_Splitfeature::createStatic(array('name' => 'foo', 'percentage' => 50));
/** @var CM_Model_Splitfeature $splitfeature2 */
$splitfeature2 = CM_Model_Splitfeature::createStatic(array('name' => 'bar', 'percentage' => 10));
$i = 0;
$userArray = array();
while ($i < 200) {
$user = CMTest_TH::createUser();
$splitfeature->getEnabled($user);
$splitfeature2->getEnabled($user);
$userArray[] = $user;
$i++;
}
CMTest_TH::clearCache();
$this->_checkEnabledFlag($userArray, $splitfeature);
$this->_checkEnabledFlag($userArray, $splitfeature2);
$splitfeature->setPercentage(99);
$this->_checkEnabledFlag($userArray, $splitfeature);
$splitfeature2->getPercentage(2);
$this->_checkEnabledFlag($userArray, $splitfeature2);
$splitfeature->setPercentage(14);
$this->_checkEnabledFlag($userArray, $splitfeature);
$splitfeature->setPercentage(66);
$this->_checkEnabledFlag($userArray, $splitfeature2);
}
示例9: tearDown
public function tearDown()
{
CMTest_TH::clearCache();
}
示例10: testOptimized
public function testOptimized()
{
/** @var CM_Model_Splittest_User $test */
$test = CM_Model_Splittest_User::create('testOptimized', ['v1', 'v2'], true);
foreach ([['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 0, 'v2' => 0]], ['variation' => 'v1', 'conversionWeight' => 0, 'UCB' => ['v1' => 0, 'v2' => 0]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 0, 'v2' => 0]], ['variation' => 'v1', 'conversionWeight' => 10, 'UCB' => ['v1' => 0, 'v2' => 9.5763354702607]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 9.162773055788501, 'v2' => 10.079050361367]], ['variation' => 'v1', 'conversionWeight' => 0, 'UCB' => ['v1' => 9.4853064449853, 'v2' => 7.4647362290016]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 6.9764490828879, 'v2' => 7.6740939911766]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.1299303954748, 'v2' => 9.3361367939935]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.2580334083849, 'v2' => 7.8752548790091]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.3676533020391, 'v2' => 8.828313974182199]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.4632468764998, 'v2' => 7.8363661837493]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.547854326983, 'v2' => 8.511152852358901]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.6236382087886, 'v2' => 7.7609849274971]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.6921892463093, 'v2' => 8.285493099313101]], ['variation' => 'v1', 'conversionWeight' => 10, 'UCB' => ['v1' => 7.7547101338294, 'v2' => 7.6828024677134]], ['variation' => 'v1', 'conversionWeight' => 0, 'UCB' => ['v1' => 9.1140386187892, 'v2' => 7.7176444685704]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.6480715270881, 'v2' => 7.7498373781205]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.6877396941039, 'v2' => 8.1724630283957]], ['variation' => 'v1', 'conversionWeight' => 10, 'UCB' => ['v1' => 7.7247529364914, 'v2' => 7.6626291437821]], ['variation' => 'v1', 'conversionWeight' => 0, 'UCB' => ['v1' => 8.5026412529014, 'v2' => 7.6867011689518]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.5231045928555, 'v2' => 7.7093347077617]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.5493610883994, 'v2' => 8.064828088657499]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.5742006691383, 'v2' => 7.6244971942451]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.5977618494541, 'v2' => 7.9347574318587]], ['variation' => 'v1', 'conversionWeight' => 10, 'UCB' => ['v1' => 7.6201641165989, 'v2' => 7.5503911157322]], ['variation' => 'v1', 'conversionWeight' => 0, 'UCB' => ['v1' => 8.1715906029488, 'v2' => 7.565588932245]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.4341829707168, 'v2' => 7.5801000881577]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.4514490087814, 'v2' => 7.8534733810622]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.4679937673471, 'v2' => 7.5106403210843]], ['variation' => 'v2', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.483872514059, 'v2' => 7.7567753416888]], ['variation' => 'v1', 'conversionWeight' => 10, 'UCB' => ['v1' => 7.4991345044317, 'v2' => 7.4490303850766]], ['variation' => 'v1', 'conversionWeight' => 0, 'UCB' => ['v1' => 7.930011605986, 'v2' => 7.4596622703966]], ['variation' => 'v2', 'conversionWeight' => 11, 'UCB' => ['v1' => 7.3403742293396, 'v2' => 7.4699083170757]]] as $fixtureData) {
CMTest_TH::clearCache();
$upperConfidenceBoundList = [];
/** @var CM_Model_SplittestVariation $variation */
foreach ($test->getVariations() as $variation) {
$upperConfidenceBoundList[$variation->getName()] = $variation->getUpperConfidenceBound();
}
$this->assertEquals($fixtureData['UCB'], $upperConfidenceBoundList);
$user = CMTest_TH::createUser();
$this->assertTrue($test->isVariationFixture($user, $fixtureData['variation']));
$test->setConversion($user, $fixtureData['conversionWeight']);
}
$test->delete();
}
示例11: testSetUserForRequestClient_userConversionBeforeLogin
public function testSetUserForRequestClient_userConversionBeforeLogin()
{
/** @var CM_Model_Splittest_RequestClient_Mock $splittestRequestClient */
$splittestRequestClient = CM_Model_Splittest_RequestClient_Mock::create('foo', ['v']);
/** @var CM_Model_Splittest_User_Mock $splittestUser */
$splittestUser = CM_Model_Splittest_User_Mock::findId($splittestRequestClient->getId());
$variation = $splittestUser->getVariationBest();
$this->assertSame(0, $variation->getFixtureCount());
$this->assertSame(0, $variation->getConversionCount());
$request = new CM_Http_Request_Post('/foo/null');
$splittestRequestClient->getVariationFixture($request);
CMTest_TH::clearCache();
$this->assertSame(1, $variation->getFixtureCount());
$this->assertSame(0, $variation->getConversionCount());
$user = CMTest_TH::createUser();
$splittestUser->setConversion($user);
CMTest_TH::clearCache();
$this->assertSame(1, $variation->getFixtureCount());
$this->assertSame(0, $variation->getConversionCount());
// Conversion ignored
$session = $request->getSession();
$session->setUser($user);
CMTest_TH::clearCache();
$this->assertSame(1, $variation->getFixtureCount());
$this->assertSame(0, $variation->getConversionCount());
$splittestUser->setConversion($user);
CMTest_TH::clearCache();
$this->assertSame(1, $variation->getFixtureCount());
$this->assertSame(1, $variation->getConversionCount());
$splittestRequestClient->delete();
CMTest_TH::clearCache();
}