本文整理汇总了PHP中CMTest_TH::getProtectedMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::getProtectedMethod方法的具体用法?PHP CMTest_TH::getProtectedMethod怎么用?PHP CMTest_TH::getProtectedMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMTest_TH
的用法示例。
在下文中一共展示了CMTest_TH::getProtectedMethod方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetRelativePathOutOfFilesystem
/**
* @expectedException CM_Exception
* @expectedExceptionMessage Path is out of filesystem directory
*/
public function testGetRelativePathOutOfFilesystem()
{
$adapter = $this->getMockBuilder('CM_File_Filesystem_Adapter')->setConstructorArgs(array('/base/base2'))->getMockForAbstractClass();
/** @var CM_File_Filesystem_Adapter $adapter */
$method = CMTest_TH::getProtectedMethod('CM_File_Filesystem_Adapter', '_getRelativePath');
$method->invoke($adapter, '/base/base2/../foo');
}
示例2: testGetCollectionName
public function testGetCollectionName()
{
CM_Config::get()->CM_Model_Abstract = new stdClass();
CM_Config::get()->CM_Model_Abstract->types = [1 => 'CMTest_ModelMock_3', 2 => 'CMTest_ModelMock_4'];
$adapter = new CM_Model_StorageAdapter_MongoDb();
$method = CMTest_TH::getProtectedMethod('CM_Model_StorageAdapter_MongoDb', '_getCollectionName');
$this->assertSame('cmtest_modelmock_3', $method->invoke($adapter, 1));
$this->assertSame('custom_table', $method->invoke($adapter, 2));
}
示例3: testGetTableName
public function testGetTableName()
{
CM_Config::get()->CM_Model_Abstract = new stdClass();
CM_Config::get()->CM_Model_Abstract->types = array(1 => 'CMTest_ModelMock_1', 2 => 'CMTest_ModelMock_2');
$adapter = new CM_Model_StorageAdapter_Database();
$method = CMTest_TH::getProtectedMethod('CM_Model_StorageAdapter_Database', '_getTableName');
$this->assertSame('cmtest_modelmock_1', $method->invoke($adapter, 1));
$this->assertSame('custom_table', $method->invoke($adapter, 2));
}
示例4: testGetCacheKey
public function testGetCacheKey()
{
CM_Config::get()->CM_Model_Abstract = new stdClass();
CM_Config::get()->CM_Model_Abstract->types = array(1 => 'CMTest_ModelMock_1', 2 => 'CMTest_ModelMock_2');
$adapter = new CM_Model_StorageAdapter_Cache();
$method = CMTest_TH::getProtectedMethod('CM_Model_StorageAdapter_Cache', '_getCacheKey');
$this->assertSame('CM_Model_StorageAdapter_Cache_type:1_id:a:1:{s:2:"id";i:2;}', $method->invoke($adapter, 1, array('id' => 2)));
$this->assertSame('CM_Model_StorageAdapter_Cache_type:2_id:a:1:{s:2:"id";i:3;}', $method->invoke($adapter, 2, array('id' => 3)));
}
示例5: testExtractTraceRow
public function testExtractTraceRow()
{
$trace = array(array('file' => 'test.php', 'line' => 18, 'function' => 'foo', 'args' => array()), array('file' => 'test.php', 'line' => 26, 'function' => 'bar', 'class' => 'Foo', 'type' => '->', 'args' => array()), array('file' => 'test.php(28) : eval()\'d code', 'line' => 1, 'function' => '{closure}', 'args' => array()), array('file' => 'test.php', 'line' => 28, 'function' => 'eval'));
$expected = array(array('code' => 'foo()', 'file' => 'test.php', 'line' => 18), array('code' => 'Foo->bar()', 'file' => 'test.php', 'line' => 26), array('code' => '{closure}()', 'file' => 'test.php(28) : eval()\'d code', 'line' => 1), array('code' => 'eval', 'file' => 'test.php', 'line' => 28));
$exception = $this->getMockBuilder('Exception')->setMethods(array('getTrace'))->getMockForAbstractClass();
$exception->expects($this->any())->method('getTrace')->will($this->returnValue($trace));
$method = CMTest_TH::getProtectedMethod('CM_ExceptionHandling_SerializableException', '_extractTraceRow');
foreach ($trace as $key => $traceRow) {
$this->assertSame($expected[$key], $method->invoke(null, $traceRow));
}
}
示例6: testIsInt
public function testIsInt()
{
$schema = new CM_Model_Schema_Definition(array());
$_isInt = CMTest_TH::getProtectedMethod('CM_Model_Schema_Definition', '_isInt');
$this->assertTrue($_isInt->invoke($schema, 1));
$this->assertTrue($_isInt->invoke($schema, '1'));
$this->assertFalse($_isInt->invoke($schema, 1.2));
$this->assertFalse($_isInt->invoke($schema, '1.0'));
$this->assertFalse($_isInt->invoke($schema, '4E2'));
$this->assertFalse($_isInt->invoke($schema, 400.0));
}
示例7: testGetPackageFromComposerPackageMissingExtra
public function testGetPackageFromComposerPackageMissingExtra()
{
$composerPackage = $this->getMockBuilder('\\Composer\\Package\\CompletePackage')->setMethods(array('getName', 'getPrettyName', 'getExtra'))->disableOriginalConstructor()->getMock();
$composerPackage->expects($this->any())->method('getName')->will($this->returnValue('foo'));
$composerPackage->expects($this->any())->method('getPrettyName')->will($this->returnValue('foo'));
$composerPackage->expects($this->any())->method('getExtra')->will($this->returnValue(array()));
/** @var \Composer\Package\CompletePackage $composerPackage */
$installation = $this->getMockBuilder('CM_App_Installation')->disableOriginalConstructor()->setMethods(array('_getComposerVendorDir'))->getMock();
$installation->expects($this->any())->method('_getComposerVendorDir')->will($this->returnValue('vendor/'));
$method = CMTest_TH::getProtectedMethod('CM_App_Installation', '_getPackageFromComposerPackage');
/** @var CM_App_Package $package */
$package = $method->invoke($installation, $composerPackage);
$this->assertSame(array(), $package->getModules());
}
示例8: testCleanUp
public function testCleanUp()
{
$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();
$this->assertSame(0, $paging->getCount());
CMTest_TH::getProtectedMethod($paging, '_add')->invoke($paging, 'foo');
$paging->_change();
$this->assertSame(1, $paging->getCount());
$age = 7 * 86400;
CMTest_TH::timeForward($age);
$paging->cleanUp();
$this->assertSame(0, $paging->getCount());
}
示例9: testLogExceptionFileLog
public function testLogExceptionFileLog()
{
$errorLog = CM_Bootloader::getInstance()->getDirTmp() . uniqid();
$log = $this->getMockBuilder('CM_Paging_Log_Error')->setMethods(array('add'))->disableOriginalConstructor()->getMock();
$log->expects($this->any())->method('add')->will($this->throwException(new Exception('foo')));
$exception = $this->getMockBuilder('CM_Exception')->setMethods(array('getLog', 'getMetaInfo'))->getMock();
$exception->expects($this->any())->method('getLog')->will($this->returnValue($log));
$exception->expects($this->any())->method('getMetaInfo')->will($this->returnValue(array()));
$method = CMTest_TH::getProtectedMethod('CM_ExceptionHandling_Handler_Abstract', 'logException');
$exceptionHandler = $this->getMockBuilder('CM_ExceptionHandling_Handler_Abstract')->setMethods(array('_getLogFile'))->getMockForAbstractClass();
$exceptionHandler->expects($this->any())->method('_getLogFile')->will($this->returnValue(new CM_File($errorLog)));
$this->assertFileNotExists($errorLog);
$method->invoke($exceptionHandler, $exception);
$logContents = file_get_contents($errorLog);
$this->assertNotEmpty($logContents);
$this->assertContains('### Cannot log error: ', $logContents);
$this->assertContains('### Original Exception: ', $logContents);
}
示例10: testDeleteOnUnsubscribeInvalid
public function testDeleteOnUnsubscribeInvalid()
{
$streamSubscribe = $this->getMockBuilder('CM_Model_Stream_Subscribe')->setMethods(array('getStreamChannel', 'getId'))->getMock();
$streamChannel = $this->getMockBuilder('CM_Model_StreamChannel_Media')->setMethods(array('isValid', 'onUnsubscribe'))->getMock();
$streamSubscribe->expects($this->any())->method('getStreamChannel')->will($this->returnValue($streamChannel));
$streamChannel->expects($this->any())->method('isValid')->will($this->returnValue(false));
$streamChannel->expects($this->never())->method('onUnsubscribe');
/** @var CM_Model_StreamChannel_Media $streamChannel */
/** @var CM_Model_Stream_Subscribe $streamSubscribe */
$onDelete = CMTest_TH::getProtectedMethod('CM_Model_Stream_Subscribe', '_onDelete');
$onDelete->invoke($streamSubscribe);
}
示例11: testSetData
public function testSetData()
{
$data = array('bar' => '23', 'foo' => 'bar');
$dataNew = array('baar' => '23', 'fooo' => 'bar');
$model = $this->getMockBuilder('CM_Model_Abstract')->setConstructorArgs(array())->getMockForAbstractClass();
/** @var CM_Model_Abstract $model */
$getData = CMTest_TH::getProtectedMethod('CM_Model_Abstract', '_getData');
$setData = CMTest_TH::getProtectedMethod('CM_Model_Abstract', '_setData');
$this->assertSame(array(), $getData->invoke($model));
$setData->invoke($model, $data);
$this->assertSame($data, $getData->invoke($model));
$setData->invoke($model, $dataNew);
$this->assertSame($dataNew, $getData->invoke($model));
}
示例12: _testIntervalModeDST
/**
* @param DateTime $start
* @param DateTimeZone $timeZone
* @throws CM_Exception_Invalid
*/
private function _testIntervalModeDST(DateTime $start, DateTimeZone $timeZone)
{
$currently = clone $start;
$managerMock = $this->mockClass('CM_Clockwork_Manager');
$managerMock->mockMethod('_getCurrentDateTimeUTC')->set(function () use(&$currently) {
return clone $currently;
});
$storageClass = $this->mockClass('CM_Clockwork_Storage_Abstract');
$storageClass->mockMethod('getLastRuntime')->set(function () use(&$lastRuntime) {
if ($lastRuntime instanceof DateTime) {
return clone $lastRuntime;
}
return $lastRuntime;
});
/** @var CM_Clockwork_Storage_FileSystem $storage */
$storage = $storageClass->newInstanceWithoutConstructor();
/** @var CM_Clockwork_Manager $manager */
$manager = $managerMock->newInstance();
$manager->setStorage($storage);
$manager->setTimeZone($timeZone);
$_shouldRun = CMTest_TH::getProtectedMethod('CM_Clockwork_Manager', '_shouldRun');
$event = new CM_Clockwork_Event('event', '20 minutes');
$lastRuntime = null;
$this->assertFalse($_shouldRun->invoke($manager, $event));
$currently->modify('19 minutes 59 seconds');
$this->assertFalse($_shouldRun->invoke($manager, $event));
$currently->modify('1 second');
$this->assertTrue($_shouldRun->invoke($manager, $event));
$lastRuntime = clone $currently;
$currently->modify('19 minutes 59 seconds');
$this->assertFalse($_shouldRun->invoke($manager, $event));
$currently->modify('1 second');
$this->assertTrue($_shouldRun->invoke($manager, $event));
$lastRuntime = clone $currently;
$currently->modify('19 minutes 59 seconds');
$this->assertFalse($_shouldRun->invoke($manager, $event));
$currently->modify('1 second');
$this->assertTrue($_shouldRun->invoke($manager, $event));
if ($timeZone->getOffset($start) === $timeZone->getOffset($currently)) {
throw new CM_Exception_Invalid("Test did not go through a daylight saving time switch");
}
}
示例13: testDeleteOnUnpublishInvalid
public function testDeleteOnUnpublishInvalid()
{
$streamPublish = $this->getMockBuilder('CM_Model_Stream_Publish')->setMethods(array('getStreamChannel', 'getId'))->getMock();
$streamChannel = $this->getMockBuilder('CM_Model_StreamChannel_Video')->setMethods(array('isValid', 'onUnpublish'))->getMock();
$streamPublish->expects($this->any())->method('getStreamChannel')->will($this->returnValue($streamChannel));
$streamChannel->expects($this->any())->method('isValid')->will($this->returnValue(false));
$streamChannel->expects($this->never())->method('onUnpublish');
/** @var CM_Model_StreamChannel_Video $streamChannel */
/** @var CM_Model_Stream_Publish $streamPublish */
$onDelete = CMTest_TH::getProtectedMethod('CM_Model_Stream_Publish', '_onDelete');
$onDelete->invoke($streamPublish);
}
示例14: testNotify
public function testNotify()
{
$actor = CMTest_TH::createUser();
$action = $this->getMockBuilder('CM_Action_Abstract')->setMethods(array('_notifyFoo', '_track'))->setConstructorArgs(array('foo', $actor))->getMockForAbstractClass();
$action->expects($this->once())->method('_notifyFoo')->with('bar');
$method = CMTest_TH::getProtectedMethod('CM_Action_Abstract', '_notify');
$method->invoke($action, 'bar');
}