本文整理汇总了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();
}
示例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);
}
示例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'));
}
示例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());
}
示例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());
}
示例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();
}
示例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();
}