本文整理汇总了PHP中CMTest_TH::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::createUser方法的具体用法?PHP CMTest_TH::createUser怎么用?PHP CMTest_TH::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMTest_TH
的用法示例。
在下文中一共展示了CMTest_TH::createUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCheckStreams
public function testCheckStreams()
{
$mockAdapter = $this->getMockForAbstractClass('CM_Stream_Adapter_Video_Abstract', array(), 'CM_Stream_Adapter_Video_Mock', true, true, true, array('_stopStream', 'getType'));
$mockAdapter->expects($this->exactly(2))->method('_stopStream')->will($this->returnValue(1));
$mockAdapter->expects($this->any())->method('getType')->will($this->returnValue(1));
CM_Config::get()->CM_Model_StreamChannel_Abstract->types[CM_Model_StreamChannel_Video_Mock::getTypeStatic()] = 'CM_Model_StreamChannel_Video_Mock';
$wowza = $wowza = $this->getMock('CM_Stream_Video', array('getAdapter'));
$wowza->expects($this->any())->method('getAdapter')->will($this->returnValue($mockAdapter));
/** @var $wowza CM_Stream_Video */
// allowedUntil will be updated, if stream has expired and its user isn't $userUnchanged, hardcoded in CM_Model_StreamChannel_Video_Mock::canSubscribe() using getOnline()
$userUnchanged = CMTest_TH::createUser();
$userUnchanged->setOnline();
$streamChannel = CM_Model_StreamChannel_Video_Mock::createStatic(array('key' => 'foo1', 'serverId' => 1, 'adapterType' => 1, 'width' => 100, 'height' => 100, 'thumbnailCount' => 0));
$streamSubscribeUnchanged1 = CM_Model_Stream_Subscribe::createStatic(array('streamChannel' => $streamChannel, 'user' => $userUnchanged, 'key' => 'foo1_2', 'start' => time()));
$streamSubscribeUnchanged2 = CM_Model_Stream_Subscribe::createStatic(array('streamChannel' => $streamChannel, 'user' => CMTest_TH::createUser(), 'key' => 'foo1_4', 'start' => time()));
$streamSubscribeChanged1 = CM_Model_Stream_Subscribe::createStatic(array('streamChannel' => $streamChannel, 'user' => CMTest_TH::createUser(), 'key' => 'foo1_3', 'start' => time()));
$streamPublishUnchanged1 = CM_Model_Stream_Publish::createStatic(array('streamChannel' => $streamChannel, 'user' => $userUnchanged, 'key' => 'foo1_2', 'start' => time()));
$streamPublishChanged1 = CM_Model_Stream_Publish::createStatic(array('streamChannel' => CM_Model_StreamChannel_Video_Mock::createStatic(array('key' => 'foo2', 'serverId' => 1, 'adapterType' => 1, 'width' => 100, 'height' => 100, 'thumbnailCount' => 0)), 'user' => CMTest_TH::createUser(), 'key' => 'foo2_1', 'start' => time()));
$this->assertSameTime($streamSubscribeUnchanged1->getAllowedUntil(), time() + 10);
$this->assertSameTime($streamSubscribeUnchanged2->getAllowedUntil(), time() + 100);
$this->assertSameTime($streamSubscribeChanged1->getAllowedUntil(), time() + 100);
$this->assertSameTime($streamPublishUnchanged1->getAllowedUntil(), time() + 10);
$this->assertSameTime($streamPublishChanged1->getAllowedUntil(), time() + 100);
CMTest_TH::timeForward(200);
$wowza->checkStreams();
$this->assertEquals($streamSubscribeUnchanged1->getAllowedUntil() + 10, $streamSubscribeUnchanged1->_change()->getAllowedUntil());
$this->assertEquals($streamSubscribeUnchanged2->getAllowedUntil() + 100, $streamSubscribeUnchanged2->_change()->getAllowedUntil());
$this->assertEquals($streamSubscribeChanged1->getAllowedUntil() + 100, $streamSubscribeChanged1->_change()->getAllowedUntil());
$this->assertEquals($streamPublishUnchanged1->getAllowedUntil() + 10, $streamPublishUnchanged1->_change()->getAllowedUntil());
$this->assertEquals($streamPublishChanged1->getAllowedUntil() + 100, $streamPublishChanged1->_change()->getAllowedUntil());
}
示例2: testTrackPageView
public function testTrackPageView()
{
$viewer = CMTest_TH::createUser();
$environment = new CM_Frontend_Environment(CM_Site_Abstract::factory(), $viewer);
$client = new CMService_AdWords_Client();
$pushConversion = new ReflectionMethod($client, '_pushConversion');
$pushConversion->setAccessible(true);
$pushConversion->invoke($client, $viewer, CMService_AdWords_Conversion::fromJson('{"google_conversion_id":123456,"google_conversion_language":"en","google_conversion_format":"1","google_conversion_color":"666666","google_conversion_label":"label","google_remarketing_only":true,"google_conversion_value":123,"google_conversion_currency":"USD","google_custom_params":{"a":1,"b":2}}'));
$pushConversion->invoke($client, $viewer, CMService_AdWords_Conversion::fromJson('{"google_conversion_id":789}'));
$this->assertSame('', $client->getJs());
$this->assertSame(<<<EOD
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script>
EOD
, $client->getHtml($environment));
$client->trackPageView($environment, '/');
$this->assertSame(<<<EOD
window.google_trackConversion({"google_conversion_id":123456,"google_conversion_language":"en","google_conversion_format":"1","google_conversion_color":"666666","google_conversion_label":"label","google_remarketing_only":true,"google_conversion_value":123,"google_conversion_currency":"USD","google_custom_params":{"a":1,"b":2}});window.google_trackConversion({"google_conversion_id":789});
EOD
, $client->getJs());
$this->assertSame(<<<EOD
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script><script type="text/javascript">
/* <![CDATA[ */
window.google_trackConversion({"google_conversion_id":123456,"google_conversion_language":"en","google_conversion_format":"1","google_conversion_color":"666666","google_conversion_label":"label","google_remarketing_only":true,"google_conversion_value":123,"google_conversion_currency":"USD","google_custom_params":{"a":1,"b":2}});window.google_trackConversion({"google_conversion_id":789});
//]]>
</script>
EOD
, $client->getHtml($environment));
}
示例3: testGetLabel_typeNotConfigured
public function testGetLabel_typeNotConfigured()
{
$actor = CMTest_TH::createUser();
$typeEmail = mt_rand();
$action = new CM_Action_Email(CM_Action_Abstract::VIEW, $actor, $typeEmail);
$this->assertSame('Email View ' . $typeEmail, $action->getLabel());
}
示例4: testGetRecordContext
public function testGetRecordContext()
{
$user = CMTest_TH::createUser();
$httpRequest = CM_Http_Request_Abstract::factory('post', '/foo?bar=1&baz=quux&viewInfoList=fooBar', ['bar' => 'baz', 'host' => 'foo.bar:8080'], ['http_referer' => 'http://bar/baz', 'http_user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_10)', 'foo' => 'quux'], '{"foo" : "bar", "quux" : "baz"}');
$clientId = $httpRequest->getClientId();
$computerInfo = new CM_Log_Context_ComputerInfo('www.example.com', 'v7.0.1');
$exception = new CM_Exception_Invalid('Bad', null, ['foo' => 'bar']);
$context = new CM_Log_Context();
$context->setExtra(['bar' => 'baz', 'baz' => 'quux']);
$context->setUser($user);
$context->setException($exception);
$context->setComputerInfo($computerInfo);
$context->setHttpRequest($httpRequest);
$contextFormatter = new CM_Log_ContextFormatter_Cargomedia('appName');
$formattedContext = $contextFormatter->formatContext($context);
$this->assertSame('www.example.com', $formattedContext['computerInfo']['fqdn']);
$this->assertSame('v7.0.1', $formattedContext['computerInfo']['phpVersion']);
$this->assertSame('/foo?bar=1&baz=quux&viewInfoList=fooBar', $formattedContext['httpRequest']['uri']);
$this->assertSame(join("\n", ['{', ' "bar": "1",', ' "baz": "quux",', ' "foo": "bar",', ' "quux": "baz"', '}']), $formattedContext['httpRequest']['query']);
$this->assertSame('POST', $formattedContext['httpRequest']['method']);
$this->assertSame('http://bar/baz', $formattedContext['httpRequest']['referer']);
$this->assertSame('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_10)', $formattedContext['httpRequest']['useragent']);
$this->assertSame('foo.bar', $formattedContext['httpRequest']['hostname']);
$this->assertSame(['id' => $user->getId(), 'displayName' => 'user' . $user->getId()], $formattedContext['appName']['user']);
$this->assertSame($clientId, $formattedContext['appName']['client']['id']);
$this->assertSame('baz', $formattedContext['appName']['bar']);
$this->assertSame('quux', $formattedContext['appName']['baz']);
$this->assertSame('CM_Exception_Invalid', $formattedContext['exception']['type']);
$this->assertSame('Bad', $formattedContext['exception']['message']);
$this->assertArrayHasKey('stack', $formattedContext['exception']);
$this->assertInternalType('string', $formattedContext['exception']['stack']);
$this->assertSame(['foo' => "'bar'"], $formattedContext['exception']['metaInfo']);
$this->assertRegExp('/library\\/CM\\/Log\\/ContextFormatter\\/CargomediaTest\\.php\\(\\d+\\)/', $formattedContext['exception']['stack']);
}
示例5: testAddGet
public function testAddGet()
{
$client = $this->getServiceManager()->getMongoDb();
$encoder = new CM_Log_Encoder_MongoDb();
$handler = new CM_Log_Handler_MongoDb($client, $encoder, CM_Paging_Log::COLLECTION_NAME);
$user = CMTest_TH::createUser();
$context = new CM_Log_Context();
$context->setExtra(['bar' => 'quux']);
$context->setUser($user);
$record1 = new CM_Log_Record(CM_Log_Logger::DEBUG, 'foo', $context);
$record2 = new CM_Log_Record(CM_Log_Logger::INFO, 'baz', new CM_Log_Context());
$handler->handleRecord($record1);
$handler->handleRecord($record2);
$paging = new CM_Paging_Log([CM_Log_Logger::DEBUG, CM_Log_Logger::INFO]);
$items = $paging->getItems();
$this->assertSame(2, count($items));
$this->assertSame('baz', $items[0]['message']);
$this->assertSame(CM_Log_Logger::INFO, $items[0]['level']);
$this->assertSame('foo', $items[1]['message']);
$this->assertSame(CM_Log_Logger::DEBUG, $items[1]['level']);
$this->assertSame($user->getDisplayName(), $items[1]['context']['user']['name']);
$this->assertSame(['bar' => 'quux', 'type' => CM_Log_Handler_MongoDb::DEFAULT_TYPE], $items[1]['context']['extra']);
$age = 86400;
CMTest_TH::timeForward($age);
CMTest_TH::timeForward($age);
$record3 = new CM_Log_Record(CM_Log_Logger::CRITICAL, 'bar', new CM_Log_Context());
$handler->handleRecord($record3);
$paging2 = new CM_Paging_Log([CM_Log_Logger::CRITICAL], null, false, $age + 1);
$items = $paging2->getItems();
$this->assertSame(1, count($items));
$this->assertSame('bar', $items[0]['message']);
$this->assertSame(CM_Log_Logger::CRITICAL, $items[0]['level']);
}
示例6: test_Get
public function test_Get()
{
$user = CMTest_TH::createUser();
$user->getRoles()->add(self::ROLE_A, 2000);
$stamps = CM_Db_Db::select('cm_role', array('startStamp', 'expirationStamp'), array('userId' => $user->getId()))->fetch();
$this->assertEquals($stamps['startStamp'], $user->getRoles()->getStartStamp(self::ROLE_A));
$this->assertEquals($stamps['expirationStamp'], $user->getRoles()->getExpirationStamp(self::ROLE_A));
}
示例7: testInvalidatedModel
public function testInvalidatedModel()
{
CM_ModelAsset_User_Preferences::setDefault('test', 'foo', false, true);
CM_ModelAsset_User_Preferences::setDefault('test', 'bar', true, true);
$user = CMTest_TH::createUser();
$user->_change();
$user->getPreferences()->getAll();
$user->getLatestActivity();
}
示例8: testProcessLanguageRedirect
public function testProcessLanguageRedirect()
{
CMTest_TH::createLanguage('en');
$response = CMTest_TH::createResponsePageEmbed('/en/mock7');
$response->process();
$this->assertNull($response->getRedirectUrl());
$response = CMTest_TH::createResponsePageEmbed('/en/mock7', null, CMTest_TH::createUser());
$response->process();
$this->assertSame($response->getSite()->getUrl() . '/mock7', $response->getRedirectUrl());
}
示例9: testOnSubscribe
public function testOnSubscribe()
{
$user = CMTest_TH::createUser();
/** @var CM_Model_StreamChannel_Message_User $channel */
$channel = CM_Model_StreamChannel_Message_User::createStatic(['key' => CM_Model_StreamChannel_Message_User::getKeyByUser($user), 'adapterType' => CM_MessageStream_Adapter_SocketRedis::getTypeStatic()]);
$this->assertSame(false, $user->getOnline());
$subscribe = CMTest_TH::createStreamSubscribe($user, $channel);
CMTest_TH::reinstantiateModel($user);
$this->assertSame(true, $user->getOnline());
}
示例10: testGetUser
public function testGetUser()
{
$user = CMTest_TH::createUser();
$streamChannel = CMTest_TH::createStreamChannel();
CMTest_TH::createStreamPublish($user, $streamChannel);
$archive = CMTest_TH::createStreamChannelVideoArchive($streamChannel);
$this->assertEquals($user, $archive->getUser());
$user->delete();
$this->assertNull($archive->getUser());
}
示例11: testPaging
public function testPaging()
{
$user = CMTest_TH::createUser();
$streamChannel = CMTest_TH::createStreamChannel();
CMTest_TH::createStreamSubscribe($user, $streamChannel);
$streams = new CM_Paging_StreamSubscribe_User($user);
$this->assertEquals(1, $streams->getCount());
$user->delete();
$streams = new CM_Paging_StreamSubscribe_User($user);
$this->assertEquals(0, $streams->getCount());
}
示例12: testJsonSerializable
public function testJsonSerializable()
{
$user = CMTest_TH::createUser();
$id = CM_Model_Entity_Mock::createStatic(array('userId' => $user->getId(), 'foo' => 'boo'));
$mock = $this->getMockBuilder('CM_Model_Entity_Mock')->setConstructorArgs(array($id->getId()))->setMethods(array('getType'))->getMock();
$mock->expects($this->any())->method('getType')->will($this->returnValue(null));
/** @var $mock CM_Model_Entity_Abstract */
$data = $mock->jsonSerialize();
$this->assertArrayHasKey('path', $data);
$this->assertNull($data['path']);
}
示例13: testContains
public function testContains()
{
$user = CMTest_TH::createUser();
$this->assertFalse((new CM_Paging_User_Online())->contains($user));
CM_Cache_Local::getInstance()->flush();
$user->setOnline(true);
$this->assertTrue((new CM_Paging_User_Online())->contains($user));
CM_Cache_Local::getInstance()->flush();
$user->setOnline(false);
$this->assertFalse((new CM_Paging_User_Online())->contains($user));
}
示例14: testConstructor
public function testConstructor()
{
$user = CMTest_TH::createUser();
$metaInfo = array('meta' => 'foo', 'user' => $user);
$severity = CM_Exception::ERROR;
$exception = new CM_Exception('foo', $severity, $metaInfo, ['messagePublic' => new CM_I18n_Phrase('foo {$bar}', ['bar' => 'foo'])]);
$render = new CM_Frontend_Render();
$this->assertSame('foo', $exception->getMessage());
$this->assertSame('foo foo', $exception->getMessagePublic($render));
$this->assertSame($severity, $exception->getSeverity());
$this->assertSame($metaInfo, $exception->getMetaInfo());
}
示例15: testLoadPageRedirectLanguage
public function testLoadPageRedirectLanguage()
{
$site = CM_Site_Abstract::factory();
CMTest_TH::createLanguage('en');
$viewer = CMTest_TH::createUser();
$environment = new CM_Frontend_Environment(null, $viewer);
$component = new CM_Page_View_Ajax_Test_Mock();
$response = $this->getResponseAjax($component, 'loadPage', ['path' => '/en' . CM_Page_View_Ajax_Test_Mock::getPath()], $environment);
$this->assertViewResponseSuccess($response);
$responseDecoded = CM_Params::jsonDecode($response->getContent());
$this->assertSame($site->getUrl() . CM_Page_View_Ajax_Test_Mock::getPath(), $responseDecoded['success']['data']['url']);
}