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


PHP StateInterface::expects方法代码示例

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


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

示例1: testSubscribing

  /**
   * Tests altering and finished event.
   *
   * @covers ::onRouteAlter
   * @covers ::onRouteFinished
   */
  public function testSubscribing() {

    // Ensure that onRouteFinished can be called without throwing notices
    // when no path roots got set.
    $this->pathRootsSubscriber->onRouteFinished();

    $route_collection = new RouteCollection();
    $route_collection->add('test_route1', new Route('/test/bar'));
    $route_collection->add('test_route2', new Route('/test/baz'));
    $route_collection->add('test_route3', new Route('/test2/bar/baz'));

    $event = new RouteBuildEvent($route_collection, 'provider');
    $this->pathRootsSubscriber->onRouteAlter($event);

    $route_collection = new RouteCollection();
    $route_collection->add('test_route4', new Route('/test1/bar'));
    $route_collection->add('test_route5', new Route('/test2/baz'));
    $route_collection->add('test_route6', new Route('/test2/bar/baz'));

    $event = new RouteBuildEvent($route_collection, 'provider');
    $this->pathRootsSubscriber->onRouteAlter($event);

    $this->state->expects($this->once())
      ->method('set')
      ->with('router.path_roots', array('test', 'test2', 'test1'));

    $this->pathRootsSubscriber->onRouteFinished();
  }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:34,代码来源:PathRootsSubscriberTest.php

示例2: testRenderInvalidType

 /**
  * Tests a CSS asset group with the invalid 'type' => 'internal'.
  */
 function testRenderInvalidType()
 {
     $this->state->expects($this->once())->method('get')->with('system.css_js_query_string')->will($this->returnValue(NULL));
     $this->setExpectedException('Exception', 'Invalid CSS asset type.');
     $css_group = array('group' => 0, 'type' => 'internal', 'media' => 'all', 'preprocess' => TRUE, 'browsers' => array(), 'data' => 'http://example.com/popular.js');
     $this->renderer->render($css_group);
 }
开发者ID:Wylbur,项目名称:gj,代码行数:10,代码来源:CssCollectionRendererUnitTest.php

示例3: testOnAlterRoutes

 /**
  * Tests the onAlterRoutes method.
  *
  * @see \Drupal\views\EventSubscriber\RouteSubscriber::onAlterRoutes()
  */
 public function testOnAlterRoutes()
 {
     $collection = new RouteCollection();
     // The first route will be overridden later.
     $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\\Tests\\Core\\Controller\\TestController')));
     $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\\Tests\\Core\\Controller\\TestController'));
     $collection->add('test_route_2', $route_2);
     $route_event = new RouteBuildEvent($collection, 'views');
     list($view, $executable, $display_1, $display_2) = $this->setupMocks();
     // The page_1 display overrides an existing route, so the dynamicRoutes
     // should only call the second display.
     $display_1->expects($this->once())->method('collectRoutes')->willReturnCallback(function () use($collection) {
         $collection->add('views.test_id.page_1', new Route('test_route', ['_content' => 'Drupal\\views\\Routing\\ViewPageController']));
         return ['test_id.page_1' => 'views.test_id.page_1'];
     });
     $display_1->expects($this->once())->method('alterRoutes')->willReturn(['test_id.page_1' => 'test_route']);
     $display_2->expects($this->once())->method('collectRoutes')->willReturnCallback(function () use($collection) {
         $collection->add('views.test_id.page_2', new Route('test_route', ['_content' => 'Drupal\\views\\Routing\\ViewPageController']));
         return ['test_id.page_2' => 'views.test_id.page_2'];
     });
     $display_2->expects($this->once())->method('alterRoutes')->willReturn([]);
     // Ensure that even both the collectRoutes() and alterRoutes() methods
     // are called on the displays, we ensure that the route first defined by
     // views is dropped.
     $this->routeSubscriber->routes();
     $this->assertNull($this->routeSubscriber->onAlterRoutes($route_event));
     $this->state->expects($this->once())->method('set')->with('views.view_route_names', array('test_id.page_1' => 'test_route', 'test_id.page_2' => 'views.test_id.page_2'));
     $collection = $route_event->getRouteCollection();
     $this->assertEquals(['test_route', 'test_route_2', 'views.test_id.page_2'], array_keys($collection->all()));
     $this->routeSubscriber->routeRebuildFinished();
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:36,代码来源:RouteSubscriberTest.php

示例4: testOnRequestOnHtml

 /**
  * Tests onRequest on a html request.
  */
 public function testOnRequestOnHtml()
 {
     $event = $this->getMockBuilder('\\Symfony\\Component\\HttpKernel\\Event\\KernelEvent')->disableOriginalConstructor()->getMock();
     $request = new Request();
     $request->setRequestFormat('html');
     $event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
     $this->routeProvider->expects($this->once())->method('preLoadRoutes')->with(['test2']);
     $this->state->expects($this->once())->method('get')->with('routing.non_admin_routes')->will($this->returnValue(array('test2')));
     $this->preloader->onRequest($event);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:RoutePreloaderTest.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->state->expects($this->once())->method('set')->with('router_rebuild_needed');
     $this->state->expects($this->once())->method('delete')->with('router_rebuild_needed');
     $this->state->expects($this->exactly(2))->method('get')->with('router_rebuild_needed')->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:anatalsceo,项目名称:en-classe,代码行数:17,代码来源:RouteBuilderTest.php

示例6: testOnAlterRoutes

 /**
  * Tests the onAlterRoutes method.
  *
  * @see \Drupal\views\EventSubscriber\RouteSubscriber::onAlterRoutes()
  */
 public function testOnAlterRoutes()
 {
     $collection = new RouteCollection();
     $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\\Tests\\Core\\Controller\\TestController')));
     $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\\Tests\\Core\\Controller\\TestController'));
     $collection->add('test_route_2', $route_2);
     $route_event = new RouteBuildEvent($collection, 'views');
     list($view, $executable, $display_1, $display_2) = $this->setupMocks();
     // The page_1 display overrides an existing route, so the dynamicRoutes
     // should only call the second display.
     $display_1->expects($this->once())->method('alterRoutes')->will($this->returnValue(array('test_id.page_1' => 'test_route')));
     $display_1->expects($this->never())->method('collectRoutes');
     $display_2->expects($this->once())->method('alterRoutes')->will($this->returnValue(array()));
     $display_2->expects($this->once())->method('collectRoutes')->will($this->returnValue(array('test_id.page_2' => 'views.test_id.page_2')));
     $this->assertNull($this->routeSubscriber->onAlterRoutes($route_event));
     // Ensure that after the alterRoutes the collectRoutes method is just called
     // once (not for page_1 anymore).
     $this->routeSubscriber->routes();
     $this->state->expects($this->once())->method('set')->with('views.view_route_names', array('test_id.page_1' => 'test_route', 'test_id.page_2' => 'views.test_id.page_2'));
     $this->routeSubscriber->routeRebuildFinished();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:26,代码来源:RouteSubscriberTest.php

示例7: testSet

 /**
  * Tests PrivateKey::setPrivateKey().
  */
 public function testSet()
 {
     $random_name = $this->randomMachineName();
     $this->state->expects($this->once())->method('set')->with('system.private_key', $random_name)->will($this->returnValue(TRUE));
     $this->privateKey->set($random_name);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:9,代码来源:PrivateKeyTest.php


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