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


PHP LockBackendInterface::expects方法代码示例

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


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

示例1: testDestruct

 /**
  * Tests the destruct method.
  *
  * @covers ::destruct
  */
 public function testDestruct()
 {
     $this->libraryDiscoveryParser->expects($this->once())->method('buildByExtension')->with('test')->will($this->returnValue($this->libraryData));
     $lock_key = 'library_info:Drupal\\Core\\Cache\\CacheCollector';
     $this->lock->expects($this->once())->method('acquire')->with($lock_key)->will($this->returnValue(TRUE));
     $this->cache->expects($this->exactly(2))->method('get')->with('library_info')->will($this->returnValue(FALSE));
     $this->cache->expects($this->once())->method('set')->with('library_info', array('test' => $this->libraryData), Cache::PERMANENT, array('library_info'));
     $this->lock->expects($this->once())->method('release')->with($lock_key);
     // This should get data and persist the key.
     $this->libraryDiscoveryCollector->get('test');
     $this->libraryDiscoveryCollector->destruct();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:17,代码来源:LibraryDiscoveryCollectorTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->storage = $this->getMock('Drupal\\locale\\StringStorageInterface');
     $this->cache = $this->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
     $this->lock = $this->getMock('Drupal\\Core\\Lock\\LockBackendInterface');
     $this->lock->expects($this->never())->method($this->anything());
     $this->user = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
     $this->user->expects($this->any())->method('getRoles')->will($this->returnValue(array('anonymous')));
     $this->configFactory = $this->getConfigFactoryStub(array('locale.settings' => array('cache_strings' => FALSE)));
     $this->languageManager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
     $container = new ContainerBuilder();
     $container->set('current_user', $this->user);
     \Drupal::setContainer($container);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:17,代码来源:LocaleLookupTest.php

示例3: testDeleteIfOwner

 /**
  * Tests the deleteIfOwner() method.
  *
  * @covers ::deleteIfOwner()
  */
 public function testDeleteIfOwner()
 {
     $this->lock->expects($this->once())->method('acquire')->with('test_2')->will($this->returnValue(TRUE));
     $this->keyValue->expects($this->at(0))->method('get')->with('test_1')->will($this->returnValue(FALSE));
     $this->keyValue->expects($this->at(1))->method('get')->with('test_2')->will($this->returnValue($this->ownObject));
     $this->keyValue->expects($this->at(2))->method('delete')->with('test_2');
     $this->keyValue->expects($this->at(3))->method('get')->with('test_3')->will($this->returnValue($this->otherObject));
     $this->assertTrue($this->tempStore->deleteIfOwner('test_1'));
     $this->assertTrue($this->tempStore->deleteIfOwner('test_2'));
     $this->assertFalse($this->tempStore->deleteIfOwner('test_3'));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:16,代码来源:TempStoreTest.php

示例4: testRebuildIfNeeded

 /**
  * Tests \Drupal\Core\Routing\RouteBuilder::rebuildIfNeeded() method.
  */
 public function testRebuildIfNeeded()
 {
     $this->lock->expects($this->once())->method('acquire')->with('router_rebuild')->will($this->returnValue(TRUE));
     $this->lock->expects($this->once())->method('release')->with('router_rebuild');
     $this->yamlDiscovery->expects($this->any())->method('findAll')->will($this->returnValue(array()));
     $this->routeBuilder->setRebuildNeeded();
     // This will trigger a successful rebuild.
     $this->assertTrue($this->routeBuilder->rebuildIfNeeded());
     // This will not trigger a rebuild.
     $this->assertFalse($this->routeBuilder->rebuildIfNeeded());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:14,代码来源:RouteBuilderTest.php

示例5: testRebuildIfNecessary

 /**
  * Tests \Drupal\Core\Routing\RouteBuilder::rebuildIfNeeded() method.
  */
 public function testRebuildIfNecessary()
 {
     $this->lock->expects($this->once())->method('acquire')->with('router_rebuild')->will($this->returnValue(TRUE));
     $this->lock->expects($this->once())->method('release')->with('router_rebuild');
     $this->routeBuilderIndicator->expects($this->once())->method('setRebuildNeeded');
     $this->routeBuilderIndicator->expects($this->once())->method('setRebuildDone');
     $this->routeBuilderIndicator->expects($this->exactly(2))->method('isRebuildNeeded')->will($this->onConsecutiveCalls(TRUE, FALSE));
     $this->yamlDiscovery->expects($this->any())->method('findAll')->will($this->returnValue(array()));
     $this->routeBuilder->setRebuildNeeded();
     // This will trigger a successful rebuild.
     $this->assertTrue($this->routeBuilder->rebuildIfNeeded());
     // This will not trigger a rebuild.
     $this->assertFalse($this->routeBuilder->rebuildIfNeeded());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:17,代码来源:RouteBuilderTest.php

示例6: testDestruct

 /**
  * Tests the destruct method.
  *
  * @covers ::destruct
  */
 public function testDestruct()
 {
     $this->activeTheme = $this->getMockBuilder('Drupal\\Core\\Theme\\ActiveTheme')->disableOriginalConstructor()->getMock();
     $this->themeManager->expects($this->once())->method('getActiveTheme')->willReturn($this->activeTheme);
     $this->activeTheme->expects($this->once())->method('getName')->willReturn('kitten_theme');
     $this->libraryDiscoveryCollector = new LibraryDiscoveryCollector($this->cache, $this->lock, $this->libraryDiscoveryParser, $this->themeManager);
     $this->libraryDiscoveryParser->expects($this->once())->method('buildByExtension')->with('test')->willReturn($this->libraryData);
     $lock_key = 'library_info:kitten_theme:Drupal\\Core\\Cache\\CacheCollector';
     $this->lock->expects($this->once())->method('acquire')->with($lock_key)->will($this->returnValue(TRUE));
     $this->cache->expects($this->exactly(2))->method('get')->with('library_info:kitten_theme')->willReturn(FALSE);
     $this->cache->expects($this->once())->method('set')->with('library_info:kitten_theme', array('test' => $this->libraryData), Cache::PERMANENT, ['library_info']);
     $this->lock->expects($this->once())->method('release')->with($lock_key);
     // This should get data and persist the key.
     $this->libraryDiscoveryCollector->get('test');
     $this->libraryDiscoveryCollector->destruct();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:21,代码来源:LibraryDiscoveryCollectorTest.php

示例7: testGetCid

 /**
  * Tests getCid()
  *
  * @covers ::getCid
  */
 public function testGetCid()
 {
     $data = $this->provider()[1];
     /** @var \Symfony\Component\HttpFoundation\Request $request */
     $request = $data[0];
     /** @var \Symfony\Component\Routing\Route $route */
     $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
     $route->setPath('/test/{b}/{a}');
     $request->attributes->get('_raw_variables')->add(['b' => 1, 'a' => 0]);
     $this->requestStack->push($request);
     $this->menuLinkManager->expects($this->any())->method('loadLinksbyRoute')->with('baby_llama')->will($this->returnValue($data[1]));
     $expected_link = $data[3];
     $expected_trail = $data[4];
     $expected_trail_ids = array_combine($expected_trail, $expected_trail);
     $this->menuLinkManager->expects($this->any())->method('getParentIds')->will($this->returnValueMap(array(array($expected_link->getPluginId(), $expected_trail_ids))));
     $this->assertSame($expected_trail_ids, $this->menuActiveTrail->getActiveTrailIds($data[2]));
     $this->cache->expects($this->once())->method('set')->with('active-trail:route:baby_llama:route_parameters:' . serialize(['a' => 0, 'b' => 1]));
     $this->lock->expects($this->any())->method('acquire')->willReturn(TRUE);
     $this->menuActiveTrail->destruct();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:25,代码来源:MenuActiveTrailTest.php


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