本文整理汇总了PHP中CMTest_TH::timeDaysForward方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::timeDaysForward方法的具体用法?PHP CMTest_TH::timeDaysForward怎么用?PHP CMTest_TH::timeDaysForward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMTest_TH
的用法示例。
在下文中一共展示了CMTest_TH::timeDaysForward方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAggregate
public function testAggregate()
{
$paging = $this->getMockBuilder('CM_Paging_Log_Abstract')->disableOriginalConstructor()->setMethods(array('getType'))->getMockForAbstractClass();
$paging->expects($this->any())->method('getType')->will($this->returnValue(1));
/** @var CM_Paging_Log_Abstract $paging */
$paging->__construct();
CMTest_TH::callProtectedMethod($paging, '_add', ['haha']);
CMTest_TH::callProtectedMethod($paging, '_add', ['huhu']);
CMTest_TH::timeDaysForward(1);
CMTest_TH::timeDaysForward(1);
CMTest_TH::callProtectedMethod($paging, '_add', ['haha']);
CMTest_TH::callProtectedMethod($paging, '_add', ['haha', array('id' => 123123, 'ip' => 1234123)]);
CMTest_TH::timeDaysForward(1);
CMTest_TH::callProtectedMethod($paging, '_add', ['ha']);
CMTest_TH::callProtectedMethod($paging, '_add', ['ha']);
CMTest_TH::callProtectedMethod($paging, '_add', ['ha']);
$paging->__construct(true, 2 * 86400);
$this->assertEquals(2, $paging->getCount());
$warning1 = $paging->getItem(0);
$warning2 = $paging->getItem(1);
$this->assertEquals(3, $warning1['count']);
$this->assertEquals(2, $warning2['count']);
$this->assertEquals('haha', $warning2['msg']);
$this->assertEquals('ha', $warning1['msg']);
}
示例2: testAdd
public function testAdd()
{
CM_Config::get()->CM_Paging_Ip_Blocked->maxAge = 3 * 86400;
$ip = '127.0.0.1';
$ip2 = '127.0.0.2';
$paging = new CM_Paging_Ip_Blocked();
$paging->add(ip2long($ip));
$this->assertEquals(1, $paging->getCount());
$entry = $paging->getItem(0);
$this->assertTrue($paging->contains(ip2long($ip)));
CMTest_TH::timeDaysForward(2);
$paging->add(ip2long($ip2));
CM_Cache_Local::getInstance()->flush();
$paging->_change();
$this->assertEquals(2, $paging->getCount());
CMTest_TH::timeDaysForward(2);
CM_Paging_Ip_Blocked::deleteOld();
CM_Cache_Local::getInstance()->flush();
$paging->_change();
$this->assertEquals(1, $paging->getCount());
CMTest_TH::timeDaysForward(2);
CM_Paging_Ip_Blocked::deleteOld();
CM_Cache_Local::getInstance()->flush();
$this->assertEquals(1, $paging->getCount());
$paging->_change();
$this->assertEquals(0, $paging->getCount());
}
示例3: testAggregate
public function testAggregate()
{
$client = $this->getServiceManager()->getMongoDb();
$encoder = new CM_Log_Encoder_MongoDb();
$handler = new CM_Log_Handler_MongoDb($client, $encoder, CM_Paging_Log::COLLECTION_NAME);
$context1 = new CM_Log_Context();
$context1->setExtra(['bar' => 'quux']);
$record1 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'foo', $context1);
$context2 = new CM_Log_Context();
$record2 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'baz', $context2);
$exception = new CM_Exception_Invalid('Bad news', CM_Exception::WARN, ['baz' => 'bar']);
$context3 = new CM_Log_Context();
$context3->setException($exception);
$record3 = new CM_Log_Record(CM_Log_Logger::WARNING, 'bar', $context3);
//they will not be found
$handler->handleRecord($record1);
$handler->handleRecord($record2);
$handler->handleRecord($record3);
CMTest_TH::timeDaysForward(2);
//recreate records to correctly set up CM_Log_Record::createdAt
$context1 = new CM_Log_Context();
$context1->setExtra(['bar' => 'quux']);
$record1 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'foo', $context1);
$context3 = new CM_Log_Context();
$context3->setException($exception);
$record3 = new CM_Log_Record(CM_Log_Logger::WARNING, 'bar', $context3);
$handler->handleRecord($record1);
$handler->handleRecord($record3);
$handler->handleRecord($record3);
CMTest_TH::timeDaysForward(1);
$exception2 = new CM_Exception_Invalid('Some info', CM_Exception::FATAL, ['foo' => 'bar']);
//recreate records to correctly set up CM_Log_Record::createdAt
$context1 = new CM_Log_Context();
$context1->setExtra(['bar' => 'quux']);
$record1 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'foo', $context1);
$context2 = new CM_Log_Context();
$record2 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'baz', $context2);
$context3 = new CM_Log_Context();
$context3->setException($exception);
$record3 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'Error bar', $context3);
$context4 = new CM_Log_Context();
$context4->setException($exception2);
$record4 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'Error bar', $context4);
$handler->handleRecord($record2);
$handler->handleRecord($record2);
$handler->handleRecord($record2);
$handler->handleRecord($record3);
$handler->handleRecord($record3);
$handler->handleRecord($record4);
$handler->handleRecord($record1);
$handler->handleRecord($record1);
$handler->handleRecord($record1);
$paging = new CM_Paging_Log([CM_Log_Logger::DEBUG], null, true, 2 * 86400);
$this->assertSame(4, $paging->getCount());
$foundRecord1 = $paging->getItem(0);
$foundRecord2 = $paging->getItem(1);
$foundRecord3 = $paging->getItem(2);
$foundRecord4 = $paging->getItem(3);
$this->assertSame(4, $foundRecord1['count']);
$this->assertSame(3, $foundRecord2['count']);
$this->assertSame(2, $foundRecord3['count']);
$this->assertSame(1, $foundRecord4['count']);
$this->assertSame('foo', $foundRecord1['message']);
$this->assertSame('baz', $foundRecord2['message']);
$this->assertSame('Error bar', $foundRecord3['message']);
$this->assertSame('Bad news', $foundRecord3['exception']['message']);
$this->assertSame('Error bar', $foundRecord4['message']);
$this->assertSame('Some info', $foundRecord4['exception']['message']);
}