当前位置: 首页>>代码示例>>PHP>>正文


PHP CMTest_TH::reinstantiateModel方法代码示例

本文整理汇总了PHP中CMTest_TH::reinstantiateModel方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::reinstantiateModel方法的具体用法?PHP CMTest_TH::reinstantiateModel怎么用?PHP CMTest_TH::reinstantiateModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMTest_TH的用法示例。


在下文中一共展示了CMTest_TH::reinstantiateModel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testProcessTranslationsEnableKey

 public function testProcessTranslationsEnableKey()
 {
     $language = CMTest_TH::createLanguage('test');
     $languageKey = CM_Model_LanguageKey::create('Hello World');
     $this->assertSame(false, $languageKey->getJavascript());
     $site = CM_Site_Abstract::factory();
     $render = new CM_Frontend_Render(new CM_Frontend_Environment(null, null, $language));
     // Check that key is *not* included in the JS translations list
     $versionJavascript = CM_Model_Language::getVersionJavascript();
     $request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
     $response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
     $response->process();
     $this->assertNotContains('Hello World', $response->getContent());
     // Request JS-enabling of language key via RPC call
     $body = CM_Params::jsonEncode(['method' => 'CM_Model_Language.requestTranslationJs', 'params' => ['Hello World']]);
     $request = new CM_Http_Request_Post('/rpc', null, null, $body);
     $response = CM_Http_Response_RPC::createFromRequest($request, $site, $this->getServiceManager());
     $response->process();
     CMTest_TH::reinstantiateModel($languageKey);
     $this->assertSame(true, $languageKey->getJavascript());
     // Check that key *is* included in the JS translations list
     $versionJavascript = CM_Model_Language::getVersionJavascript();
     $request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
     $response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
     $response->process();
     $this->assertContains('Hello World', $response->getContent());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:27,代码来源:LibraryTest.php

示例2: testOnRedisMessageSubscribe

 public function testOnRedisMessageSubscribe()
 {
     $adapter = new CM_MessageStream_Adapter_SocketRedis([]);
     $message = array('type' => 'subscribe', 'data' => array('channel' => 'foo:' . CM_Model_StreamChannel_Message::getTypeStatic(), 'clientKey' => 'bar', 'data' => array()));
     $adapter->onRedisMessage(json_encode($message));
     $timeStarted = time();
     $streamChannel = CM_Model_StreamChannel_Message::findByKeyAndAdapter('foo', $adapter->getType());
     $this->assertNotNull($streamChannel);
     $streamChannels = new CM_Paging_StreamChannel_AdapterType($adapter->getType());
     $this->assertSame(1, $streamChannels->getCount());
     $streamSubscribe = CM_Model_Stream_Subscribe::findByKeyAndChannel('bar', $streamChannel);
     $this->assertNotNull($streamSubscribe);
     $this->assertSame(1, $streamChannel->getStreamSubscribes()->getCount());
     $this->assertSameTime($timeStarted, $streamSubscribe->getStart());
     $this->assertSameTime($streamChannel->canSubscribe(null, time()), $streamSubscribe->getAllowedUntil());
     $this->assertNull($streamSubscribe->getUser());
     CMTest_TH::timeForward(CM_MessageStream_Adapter_SocketRedis::SYNCHRONIZE_DELAY);
     $adapter->onRedisMessage(json_encode($message));
     $streamChannels = new CM_Paging_StreamChannel_AdapterType($adapter->getType());
     $this->assertSame(1, $streamChannels->getCount());
     $this->assertSame(1, $streamChannel->getStreamSubscribes()->getCount());
     CMTest_TH::reinstantiateModel($streamSubscribe);
     $this->assertSameTime($timeStarted, $streamSubscribe->getStart());
     $this->assertSameTime($streamChannel->canSubscribe(null, $timeStarted), $streamSubscribe->getAllowedUntil());
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:25,代码来源:SocketRedisTest.php

示例3: testSetOptimized

 public function testSetOptimized()
 {
     /** @var CM_Model_Splittest $test */
     $test = CM_Model_Splittest::create('foo', ['v1']);
     $this->assertSame(false, $test->getOptimized());
     $test->setOptimized(true);
     CMTest_TH::clearCache();
     CMTest_TH::reinstantiateModel($test);
     $this->assertSame(true, $test->getOptimized());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:10,代码来源:SplittestTest.php

示例4: 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());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:10,代码来源:UserTest.php

示例5: testOnDelete

 public function testOnDelete()
 {
     /** @var CM_Model_StreamChannel_Media $streamChannel */
     $streamChannel = CMTest_TH::createStreamChannel();
     $streamChannel->delete();
     $exception = $this->catchException(function () use($streamChannel) {
         CMTest_TH::reinstantiateModel($streamChannel);
     });
     $this->assertInstanceOf('CM_Exception_Nonexistent', $exception);
     $this->assertInstanceOf('CM_Model_StreamChannelArchive_Media', CM_Model_StreamChannelArchive_Media::findById($streamChannel->getId()));
 }
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:MediaTest.php

示例6: testExecute

 public function testExecute()
 {
     $user = CMTest_TH::createUser();
     $user->setOnline();
     $userChannel = CM_Model_StreamChannel_Message_User::createStatic(['key' => CM_Model_StreamChannel_Message_User::getKeyByUser($user), 'adapterType' => CM_MessageStream_Adapter_SocketRedis::getTypeStatic()]);
     $job = new CM_User_OfflineJob();
     $this->assertSame(true, $user->getOnline());
     $job->run(['user' => $user]);
     CMTest_TH::reinstantiateModel($user);
     $this->assertSame(true, $user->getOnline());
     $userChannel->delete();
     $job->run(['user' => $user]);
     CMTest_TH::reinstantiateModel($user);
     $this->assertSame(false, $user->getOnline());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:15,代码来源:OfflineJobTest.php

示例7: assertModelNotInstantiable

 /**
  * @param CM_Model_Abstract $model
  * @param string|null       $message
  */
 public static function assertModelNotInstantiable(CM_Model_Abstract $model, $message = null)
 {
     $message = null !== $message ? (string) $message : 'Model can be instantiated';
     try {
         CMTest_TH::reinstantiateModel($model);
         self::fail($message);
     } catch (CM_Exception_Nonexistent $ex) {
         self::assertTrue(true);
     }
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:14,代码来源:TestCase.php

示例8: testDeleteOlder

 public function testDeleteOlder()
 {
     $time = time();
     /** @var CM_Model_StreamChannel_Video $streamChannel */
     $streamChannelsDeleted = array();
     $archivesDeleted = array();
     /** @var $filesDeleted CM_File[] */
     $filesDeleted = array();
     for ($i = 0; $i < 2; $i++) {
         $streamChannel = CMTest_TH::createStreamChannel();
         $streamChannel->setThumbnailCount(4);
         $streamChannelsDeleted[] = $streamChannel;
         $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannel);
         $archivesDeleted[] = $archive;
         $filesDeleted = array_merge($filesDeleted, $this->_createArchiveFiles($archive));
     }
     $streamChannelsNotDeleted = array();
     $archivesNotDeleted = array();
     /** @var $filesNotDeleted CM_File[] */
     $filesNotDeleted = array();
     $streamChannel = CMTest_TH::createStreamChannel();
     $streamChannel = $this->getMock('CM_Model_StreamChannel_Video', array('getType'), array($streamChannel->getId()));
     $streamChannel->expects($this->any())->method('getType')->will($this->returnValue(3));
     $streamChannelsNotDeleted[] = $streamChannel;
     $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannel);
     $archivesNotDeleted[] = $archive;
     $filesNotDeleted = array_merge($filesNotDeleted, $this->_createArchiveFiles($archive));
     CMTest_TH::timeForward(20);
     for ($i = 0; $i < 3; $i++) {
         $streamChannel = CMTest_TH::createStreamChannel();
         $streamChannel->setThumbnailCount(4);
         $streamChannelsNotDeleted[] = $streamChannel;
         $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannel);
         $archivesNotDeleted[] = $archive;
         $filesNotDeleted = array_merge($filesNotDeleted, $this->_createArchiveFiles($archive));
     }
     foreach ($filesNotDeleted as $file) {
         $this->assertTrue($file->exists());
     }
     foreach ($filesDeleted as $file) {
         $this->assertTrue($file->exists());
     }
     CM_Model_StreamChannelArchive_Video::deleteOlder(10, CM_Model_StreamChannel_Video::getTypeStatic());
     foreach ($filesNotDeleted as $file) {
         $this->assertTrue($file->exists());
     }
     foreach ($filesDeleted as $file) {
         $this->assertFalse($file->exists());
     }
     foreach ($archivesNotDeleted as $archive) {
         try {
             CMTest_TH::reinstantiateModel($archive);
             $this->assertTrue(true);
         } catch (CM_Exception_Nonexistent $ex) {
             $this->fail('Young streamchannelArchive deleted');
         }
     }
     foreach ($archivesDeleted as $archive) {
         try {
             CMTest_TH::reinstantiateModel($archive);
             $this->fail('Old streamchannelArchive not deleted');
         } catch (CM_Exception_Nonexistent $ex) {
             $this->assertTrue(true);
         }
     }
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:66,代码来源:VideoTest.php

示例9: testDeleteOlder

 public function testDeleteOlder()
 {
     $archivesDeleted = [];
     $archivesNotDeleted = [];
     for ($i = 0; $i < 2; $i++) {
         $archive = CMTest_TH::createStreamChannelVideoArchive();
         $archivesDeleted[] = $archive;
     }
     $streamChannel = CMTest_TH::createStreamChannel();
     $mockBuilder = $this->getMockBuilder('CM_Model_StreamChannel_Media');
     $mockBuilder->setMethods(['getType']);
     $mockBuilder->setConstructorArgs([$streamChannel->getId()]);
     $streamChannelMock = $mockBuilder->getMock();
     $streamChannelMock->expects($this->any())->method('getType')->will($this->returnValue(3));
     $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannelMock);
     $archivesNotDeleted[] = $archive;
     CMTest_TH::timeForward(20);
     for ($i = 0; $i < 3; $i++) {
         $archive = CMTest_TH::createStreamChannelVideoArchive();
         $archivesNotDeleted[] = $archive;
     }
     $this->assertCount(6, new CM_Paging_StreamChannelArchiveMedia_All());
     CM_Model_StreamChannelArchive_Media::deleteOlder(10, CM_Model_StreamChannel_Media::getTypeStatic());
     $this->assertCount(4, new CM_Paging_StreamChannelArchiveMedia_All());
     foreach ($archivesNotDeleted as $archive) {
         $exception = $this->catchException(function () use($archive) {
             CMTest_TH::reinstantiateModel($archive);
         });
         $this->assertNull($exception, 'Deleted archive that was too young or the wrong type');
     }
     foreach ($archivesDeleted as $archive) {
         $exception = $this->catchException(function () use($archive) {
             CMTest_TH::reinstantiateModel($archive);
         });
         $this->assertInstanceOf('CM_Exception_Nonexistent', $exception, 'Didn\'t delete old archive');
     }
 }
开发者ID:cargomedia,项目名称:cm,代码行数:37,代码来源:MediaTest.php


注:本文中的CMTest_TH::reinstantiateModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。