コード例 #1
0
ファイル: NodeBulkFormTest.php プロジェクト: ddrozdik/dmaps
 /**
  * Tests the constructor assignment of actions.
  */
 public function testConstructor()
 {
     $actions = array();
     for ($i = 1; $i <= 2; $i++) {
         $action = $this->getMock('\\Drupal\\system\\ActionConfigEntityInterface');
         $action->expects($this->any())->method('getType')->will($this->returnValue('node'));
         $actions[$i] = $action;
     }
     $action = $this->getMock('\\Drupal\\system\\ActionConfigEntityInterface');
     $action->expects($this->any())->method('getType')->will($this->returnValue('user'));
     $actions[] = $action;
     $entity_storage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $entity_storage->expects($this->any())->method('loadMultiple')->will($this->returnValue($actions));
     $entity_manager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $entity_manager->expects($this->once())->method('getStorage')->with('action')->will($this->returnValue($entity_storage));
     $language_manager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
     $views_data = $this->getMockBuilder('Drupal\\views\\ViewsData')->disableOriginalConstructor()->getMock();
     $views_data->expects($this->any())->method('get')->with('node')->will($this->returnValue(array('table' => array('entity type' => 'node'))));
     $container = new ContainerBuilder();
     $container->set('views.views_data', $views_data);
     $container->set('string_translation', $this->getStringTranslationStub());
     \Drupal::setContainer($container);
     $storage = $this->getMock('Drupal\\views\\ViewEntityInterface');
     $storage->expects($this->any())->method('get')->with('base_table')->will($this->returnValue('node'));
     $executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->getMock();
     $executable->storage = $storage;
     $display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')->disableOriginalConstructor()->getMock();
     $definition['title'] = '';
     $options = array();
     $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_manager, $language_manager);
     $node_bulk_form->init($executable, $display, $options);
     $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
 }
コード例 #2
0
 /**
  * @covers ::create
  * @covers ::__construct
  */
 public function testCreate()
 {
     $container = new ContainerBuilder();
     $container->set('keyvalue.expirable', $this->prophesize('Drupal\\Core\\KeyValueStore\\KeyValueExpirableFactoryInterface')->reveal());
     $container->set('entity.manager', $this->entityManager->reveal());
     $this->assertInstanceOf('Drupal\\feeds\\Controller\\SubscriptionController', SubscriptionController::create($container));
 }
コード例 #3
0
 /**
  * Tests the listing of displays on a views list builder.
  *
  * @see \Drupal\views_ui\ViewListBuilder::getDisplaysList()
  * @covers ::buildRow
  */
 public function testBuildRowEntityList()
 {
     $storage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')->disableOriginalConstructor()->getMock();
     $display_manager = $this->getMockBuilder('\\Drupal\\views\\Plugin\\ViewsPluginManager')->disableOriginalConstructor()->getMock();
     $display_manager->expects($this->any())->method('getDefinition')->will($this->returnValueMap(array(array('default', TRUE, array('id' => 'default', 'title' => 'Master', 'theme' => 'views_view', 'no_ui' => TRUE, 'admin' => '')), array('page', TRUE, array('id' => 'page', 'title' => 'Page', 'uses_menu_links' => TRUE, 'uses_route' => TRUE, 'contextual_links_locations' => array('page'), 'theme' => 'views_view', 'admin' => 'Page admin label')), array('embed', TRUE, array('id' => 'embed', 'title' => 'embed', 'theme' => 'views_view', 'admin' => 'Embed admin label')))));
     $default_display = $this->getMock('Drupal\\views\\Plugin\\views\\display\\DefaultDisplay', array('initDisplay'), array(array(), 'default', $display_manager->getDefinition('default')));
     $route_provider = $this->getMock('Drupal\\Core\\Routing\\RouteProviderInterface');
     $state = $this->getMock('\\Drupal\\Core\\State\\StateInterface');
     $menu_storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
     $page_display = $this->getMock('Drupal\\views\\Plugin\\views\\display\\Page', array('initDisplay', 'getPath'), array(array(), 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage));
     $page_display->expects($this->any())->method('getPath')->will($this->onConsecutiveCalls($this->returnValue('test_page'), $this->returnValue('<object>malformed_path</object>'), $this->returnValue('<script>alert("placeholder_page/%")</script>')));
     $embed_display = $this->getMock('Drupal\\views\\Plugin\\views\\display\\Embed', array('initDisplay'), array(array(), 'default', $display_manager->getDefinition('embed')));
     $values = array();
     $values['status'] = FALSE;
     $values['display']['default']['id'] = 'default';
     $values['display']['default']['display_title'] = 'Display';
     $values['display']['default']['display_plugin'] = 'default';
     $values['display']['page_1']['id'] = 'page_1';
     $values['display']['page_1']['display_title'] = 'Page 1';
     $values['display']['page_1']['display_plugin'] = 'page';
     $values['display']['page_1']['display_options']['path'] = 'test_page';
     $values['display']['page_2']['id'] = 'page_2';
     $values['display']['page_2']['display_title'] = 'Page 2';
     $values['display']['page_2']['display_plugin'] = 'page';
     $values['display']['page_2']['display_options']['path'] = '<object>malformed_path</object>';
     $values['display']['page_3']['id'] = 'page_3';
     $values['display']['page_3']['display_title'] = 'Page 3';
     $values['display']['page_3']['display_plugin'] = 'page';
     $values['display']['page_3']['display_options']['path'] = '<script>alert("placeholder_page/%")</script>';
     $values['display']['embed']['id'] = 'embed';
     $values['display']['embed']['display_title'] = 'Embedded';
     $values['display']['embed']['display_plugin'] = 'embed';
     $display_manager->expects($this->any())->method('createInstance')->will($this->returnValueMap(array(array('default', $values['display']['default'], $default_display), array('page', $values['display']['page_1'], $page_display), array('page', $values['display']['page_2'], $page_display), array('page', $values['display']['page_3'], $page_display), array('embed', $values['display']['embed'], $embed_display))));
     $container = new ContainerBuilder();
     $user = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
     $request_stack = new RequestStack();
     $request_stack->push(new Request());
     $views_data = $this->getMockBuilder('Drupal\\views\\ViewsData')->disableOriginalConstructor()->getMock();
     $route_provider = $this->getMock('Drupal\\Core\\Routing\\RouteProviderInterface');
     $executable_factory = new ViewExecutableFactory($user, $request_stack, $views_data, $route_provider);
     $container->set('views.executable', $executable_factory);
     $container->set('plugin.manager.views.display', $display_manager);
     \Drupal::setContainer($container);
     // Setup a view list builder with a mocked buildOperations method,
     // because t() is called on there.
     $entity_type = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface');
     $view_list_builder = new TestViewListBuilder($entity_type, $storage, $display_manager);
     $view_list_builder->setStringTranslation($this->getStringTranslationStub());
     $view = new View($values, 'view');
     $row = $view_list_builder->buildRow($view);
     $expected_displays = array('Embed admin label', 'Page admin label', 'Page admin label', 'Page admin label');
     $this->assertEquals($expected_displays, $row['data']['view_name']['data']['#displays']);
     $display_paths = $row['data']['path']['data']['#items'];
     // These values will be escaped by Twig when rendered.
     $this->assertEquals('/test_page, /<object>malformed_path</object>, /<script>alert("placeholder_page/%")</script>', implode(', ', $display_paths));
     $this->assertFalse(SafeMarkup::isSafe('/<object>malformed_path</object>'), '/<script>alert("/<object>malformed_path</object> is not marked safe.');
     $this->assertFalse(SafeMarkup::isSafe('/<script>alert("placeholder_page/%")'), '/<script>alert("/<script>alert("placeholder_page/%") is not marked safe.');
 }
コード例 #4
0
 /**
  * Setup access plugin manager and config factory in the Drupal class.
  */
 public function setupContainer()
 {
     $this->accessPluginManager = $this->getMockBuilder('\\Drupal\\views\\Plugin\\ViewsPluginManager')->disableOriginalConstructor()->getMock();
     $container = new ContainerBuilder();
     $container->set('plugin.manager.views.access', $this->accessPluginManager);
     $config = array('views.settings' => array('skip_cache' => TRUE, 'display_extenders' => array()));
     $container->set('config.factory', $this->getConfigFactoryStub($config));
     \Drupal::setContainer($container);
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('uuid', $this->uuid);
     \Drupal::setContainer($container);
 }
コード例 #6
0
ファイル: EntityUrlTest.php プロジェクト: aWEBoLabs/taxi
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->urlGenerator = $this->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('url_generator', $this->urlGenerator);
     \Drupal::setContainer($container);
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->urlGenerator = $this->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $this->urlGenerator->expects($this->any())->method('generateFromPath')->will($this->returnArgument(0));
     $this->router = $this->getMock('Drupal\\Tests\\Core\\Routing\\TestRouterInterface');
     $container = new ContainerBuilder();
     $container->set('router', $this->router);
     $container->set('url_generator', $this->urlGenerator);
     \Drupal::setContainer($container);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->typedDataManager = $this->prophesize(TypedDataManager::class);
     $container = new ContainerBuilder();
     $container->set('string_translation', $this->getStringTranslationStub());
     $container->set('typed_data_manager', $this->typedDataManager->reveal());
     \Drupal::setContainer($container);
     $this->page = $this->prophesize(PageInterface::class);
     $this->event = new PageManagerContextEvent($this->page->reveal());
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->typedDataManager = $this->prophesize(TypedDataManager::class);
     $container = new ContainerBuilder();
     $container->set('string_translation', $this->getStringTranslationStub());
     $container->set('typed_data_manager', $this->typedDataManager->reveal());
     \Drupal::setContainer($container);
     $this->executable = $this->getMockBuilder(PageExecutable::class)->disableOriginalConstructor()->setMethods(['getPage', 'addContext'])->getMock();
     $this->event = new PageManagerContextEvent($this->executable);
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 protected function setUp() {
   parent::setUp();
   // Organize our mock container.
   $container = new ContainerBuilder();
   $container->set('app.root', self::$root);
   $file_system = $this->prophesize(FileSystemInterface::class);
   // The simpletest directory wrapper will always point to /tmp.
   $file_system->realpath('public://simpletest')->willReturn(sys_get_temp_dir());
   $container->set('file_system', $file_system->reveal());
   \Drupal::setContainer($container);
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
     $this->fieldTypeManager = $this->getMock(FieldTypePluginManagerInterface::class);
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('uuid', $this->uuid);
     $container->set('plugin.manager.field.field_type', $this->fieldTypeManager);
     \Drupal::setContainer($container);
 }
コード例 #12
0
 /**
  * @expectedException \RuntimeException
  */
 public function test()
 {
     $container = new ContainerBuilder();
     $container->set('queue', $this->getMock('Drupal\\Core\\Queue\\QueueFactory', [], [], '', FALSE));
     $container->set('event_dispatcher', new EventDispatcher());
     $plugin = $this->getMockForAbstractClass('Drupal\\feeds\\Plugin\\QueueWorker\\FeedQueueWorkerBase', [], '', FALSE);
     $plugin = $plugin::create($container, [], '', []);
     $method = $this->getProtectedClosure($plugin, 'handleException');
     $method($this->getMockFeed(), new EmptyFeedException());
     $method($this->getMockFeed(), new \RuntimeException());
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->urlAssembler = $this->getMock('Drupal\\Core\\Utility\\UnroutedUrlAssemblerInterface');
     $this->urlAssembler->expects($this->any())->method('assemble')->will($this->returnArgument(0));
     $this->router = $this->getMock('Drupal\\Tests\\Core\\Routing\\TestRouterInterface');
     $container = new ContainerBuilder();
     $container->set('router.no_access_checks', $this->router);
     $container->set('unrouted_url_assembler', $this->urlAssembler);
     \Drupal::setContainer($container);
 }
コード例 #14
0
ファイル: FeedParseTest.php プロジェクト: Tawreh/mtg
 public function setUp()
 {
     parent::setUp();
     $container = new ContainerBuilder();
     $this->dispatcher = new EventDispatcher();
     $queue_factory = $this->getMock('Drupal\\Core\\Queue\\QueueFactory', [], [], '', FALSE);
     $queue_factory->expects($this->any())->method('get')->with('feeds_feed_process:')->will($this->returnValue($this->getMock('Drupal\\Core\\Queue\\QueueInterface')));
     $container->set('queue', $queue_factory);
     $container->set('event_dispatcher', $this->dispatcher);
     $this->plugin = FeedParse::create($container, [], 'feeds_feed_parse', []);
     $this->feed = $this->getMockFeed();
 }
コード例 #15
0
 /**
  * Tests set with a synchronized service.
  */
 public function testSetOnSynchronizedService()
 {
     $container = new ContainerBuilder();
     $container->register('baz', 'BazClass')->setSynchronized(TRUE);
     $container->register('bar', 'BarClass')->addMethodCall('setBaz', array(new Reference('baz')));
     // Ensure that we can set services on a compiled container.
     $container->compile();
     $container->set('baz', $baz = new \BazClass());
     $this->assertSame($baz, $container->get('bar')->getBaz());
     $container->set('baz', $baz = new \BazClass());
     $this->assertSame($baz, $container->get('bar')->getBaz());
 }
コード例 #16
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityType = $this->randomMachineName();
     $this->entityInfo = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityInfo->expects($this->any())->method('getProvider')->will($this->returnValue('entity'));
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('uuid', $this->uuid);
     \Drupal::setContainer($container);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('responsive_image'));
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with('responsive_image_style')->will($this->returnValue($this->entityType));
     $this->breakpointManager = $this->getMock('\\Drupal\\breakpoint\\BreakpointManagerInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('breakpoint.manager', $this->breakpointManager);
     \Drupal::setContainer($container);
 }
コード例 #18
0
ファイル: EntityLinkTest.php プロジェクト: ddrozdik/dmaps
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->linkGenerator = $this->getMock('Drupal\\Core\\Utility\\LinkGeneratorInterface');
     $this->languageManager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('link_generator', $this->linkGenerator);
     $container->set('language_manager', $this->languageManager);
     \Drupal::setContainer($container);
 }
コード例 #19
0
ファイル: ViewTest.php プロジェクト: anatalsceo/en-classe
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     // Setup the entity manager.
     $entity_definition = new EntityType(array('id' => 'view'));
     $entity_manager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $entity_manager->expects($this->any())->method('getDefinition')->will($this->returnValue($entity_definition));
     $container_builder = new ContainerBuilder();
     $container_builder->set('entity.manager', $entity_manager);
     // Setup the string translation.
     $string_translation = $this->getStringTranslationStub();
     $container_builder->set('string_translation', $string_translation);
     \Drupal::setContainer($container_builder);
 }
コード例 #20
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->entityTypeId = $this->randomName();
     $this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('breakpoint'));
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
     $this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('uuid', $this->uuid);
     \Drupal::setContainer($container);
 }
コード例 #21
0
ファイル: EntityManagerTest.php プロジェクト: aWEBoLabs/taxi
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
     $this->entityTypeRepository = $this->prophesize(EntityTypeRepositoryInterface::class);
     $this->entityTypeBundleInfo = $this->prophesize(EntityTypeBundleInfoInterface::class);
     $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class);
     $container = new ContainerBuilder();
     $container->set('entity_type.manager', $this->entityTypeManager->reveal());
     $container->set('entity_type.repository', $this->entityTypeRepository->reveal());
     $container->set('entity_type.bundle.info', $this->entityTypeBundleInfo->reveal());
     $container->set('entity_field.manager', $this->entityFieldManager->reveal());
     $this->entityManager = new EntityManager();
     $this->entityManager->setContainer($container);
 }
コード例 #22
0
ファイル: RenderElementTest.php プロジェクト: ddrozdik/dmaps
 /**
  * @covers ::preRenderAjaxForm
  */
 public function testPreRenderAjaxFormWithQueryOptions()
 {
     $request = Request::create('/test');
     $request->query->set('foo', 'bar');
     $this->requestStack->push($request);
     $prophecy = $this->prophesize('Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $url = '/test?foo=bar&other=query&ajax_form=1';
     $prophecy->generateFromRoute('<current>', [], ['query' => ['foo' => 'bar', 'other' => 'query', FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]], TRUE)->willReturn((new GeneratedUrl())->setCacheContexts(['route'])->setGeneratedUrl($url));
     $url_generator = $prophecy->reveal();
     $this->container->set('url_generator', $url_generator);
     $element = ['#type' => 'select', '#id' => 'test', '#ajax' => ['wrapper' => 'foo', 'callback' => 'test-callback', 'options' => ['query' => ['other' => 'query']]]];
     $element = RenderElement::preRenderAjaxForm($element);
     $this->assertTrue($element['#ajax_processed']);
     $this->assertEquals($url, $element['#attached']['drupalSettings']['ajax']['test']['url']);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityTypeId = $this->randomMachineName();
     $this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
     $this->typedConfigManager = $this->getMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
     $this->configEntityStorageInterface = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('uuid', $this->uuid);
     $container->set('config.typed', $this->typedConfigManager);
     $container->set('config.storage', $this->configEntityStorageInterface);
     \Drupal::setContainer($container);
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->pageVariant = new PageVariant(['id' => 'the_page_variant', 'page' => 'the_page'], 'page_variant');
     $this->page = $this->prophesize(PageInterface::class);
     $entity_storage = $this->prophesize(EntityStorageInterface::class);
     $entity_storage->load('the_page')->willReturn($this->page->reveal());
     $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
     $entity_type_manager->getStorage('page')->willReturn($entity_storage);
     $this->contextMapper = $this->prophesize(ContextMapperInterface::class);
     $container = new ContainerBuilder();
     $container->set('entity_type.manager', $entity_type_manager->reveal());
     $container->set('page_manager.context_mapper', $this->contextMapper->reveal());
     \Drupal::setContainer($container);
 }
コード例 #25
0
ファイル: ViewsBlockTest.php プロジェクト: ddrozdik/dmaps
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // TODO: Change the autogenerated stub
     $condition_plugin_manager = $this->getMock('Drupal\\Core\\Executable\\ExecutableManagerInterface');
     $condition_plugin_manager->expects($this->any())->method('getDefinitions')->will($this->returnValue(array()));
     $container = new ContainerBuilder();
     $container->set('plugin.manager.condition', $condition_plugin_manager);
     \Drupal::setContainer($container);
     $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->setMethods(['buildRenderable', 'setDisplay', 'setItemsPerPage'])->getMock();
     $this->executable->expects($this->any())->method('setDisplay')->with('block_1')->will($this->returnValue(TRUE));
     $this->executable->expects($this->any())->method('getShowAdminLinks')->willReturn(FALSE);
     $this->executable->display_handler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')->disableOriginalConstructor()->setMethods(NULL)->getMock();
     $this->view = $this->getMockBuilder('Drupal\\views\\Entity\\View')->disableOriginalConstructor()->getMock();
     $this->view->expects($this->any())->method('id')->willReturn('test_view');
     $this->executable->storage = $this->view;
     $this->executableFactory = $this->getMockBuilder('Drupal\\views\\ViewExecutableFactory')->disableOriginalConstructor()->getMock();
     $this->executableFactory->expects($this->any())->method('get')->with($this->view)->will($this->returnValue($this->executable));
     $this->displayHandler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')->disableOriginalConstructor()->getMock();
     $this->displayHandler->expects($this->any())->method('blockSettings')->willReturn([]);
     $this->displayHandler->expects($this->any())->method('getPluginId')->willReturn('block');
     $this->executable->display_handler = $this->displayHandler;
     $this->storage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')->disableOriginalConstructor()->getMock();
     $this->storage->expects($this->any())->method('load')->with('test_view')->will($this->returnValue($this->view));
     $this->account = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
 }
コード例 #26
0
 /**
  * @covers ::getOperations
  */
 public function testGetOperations()
 {
     $operation_name = $this->randomMachineName();
     $operations = array($operation_name => array('title' => $this->randomMachineName()));
     $this->moduleHandler->expects($this->once())->method('invokeAll')->with('entity_operation', array($this->role))->will($this->returnValue($operations));
     $this->moduleHandler->expects($this->once())->method('alter')->with('entity_operation');
     $this->container->set('module_handler', $this->moduleHandler);
     $this->role->expects($this->any())->method('access')->will($this->returnValue(AccessResult::allowed()));
     $this->role->expects($this->any())->method('hasLinkTemplate')->will($this->returnValue(TRUE));
     $url = $this->getMockBuilder('\\Drupal\\Core\\Url')->disableOriginalConstructor()->getMock();
     $url->expects($this->any())->method('toArray')->will($this->returnValue(array()));
     $this->role->expects($this->any())->method('urlInfo')->will($this->returnValue($url));
     $list = new EntityListBuilder($this->entityType, $this->roleStorage, $this->moduleHandler);
     $list->setStringTranslation($this->translationManager);
     $operations = $list->getOperations($this->role);
     $this->assertInternalType('array', $operations);
     $this->assertArrayHasKey('edit', $operations);
     $this->assertInternalType('array', $operations['edit']);
     $this->assertArrayHasKey('title', $operations['edit']);
     $this->assertArrayHasKey('delete', $operations);
     $this->assertInternalType('array', $operations['delete']);
     $this->assertArrayHasKey('title', $operations['delete']);
     $this->assertArrayHasKey($operation_name, $operations);
     $this->assertInternalType('array', $operations[$operation_name]);
     $this->assertArrayHasKey('title', $operations[$operation_name]);
 }
コード例 #27
0
 /**
  * Tests the title_query method.
  *
  * @see \Drupal\user\Plugin\views\argument\RolesRid::title_query()
  */
 public function testTitleQuery()
 {
     $role1 = new Role(array('id' => 'test_rid_1', 'label' => 'test rid 1'), 'user_role');
     $role2 = new Role(array('id' => 'test_rid_2', 'label' => 'test <strong>rid 2</strong>'), 'user_role');
     // Creates a stub entity storage;
     $role_storage = $this->getMockForAbstractClass('Drupal\\Core\\Entity\\EntityStorageInterface');
     $role_storage->expects($this->any())->method('loadMultiple')->will($this->returnValueMap(array(array(array(), array()), array(array('test_rid_1'), array('test_rid_1' => $role1)), array(array('test_rid_1', 'test_rid_2'), array('test_rid_1' => $role1, 'test_rid_2' => $role2)))));
     $entity_type = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface');
     $entity_type->expects($this->any())->method('getKey')->with('label')->will($this->returnValue('label'));
     $entity_manager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $entity_manager->expects($this->any())->method('getDefinition')->with($this->equalTo('user_role'))->will($this->returnValue($entity_type));
     $entity_manager->expects($this->once())->method('getStorage')->with($this->equalTo('user_role'))->will($this->returnValue($role_storage));
     // @todo \Drupal\Core\Entity\Entity::entityType() uses a global call to
     //   entity_get_info(), which in turn wraps \Drupal::entityManager(). Set
     //   the entity manager until this is fixed.
     $container = new ContainerBuilder();
     $container->set('entity.manager', $entity_manager);
     \Drupal::setContainer($container);
     $roles_rid_argument = new RolesRid(array(), 'user__roles_rid', array(), $entity_manager);
     $roles_rid_argument->value = array();
     $titles = $roles_rid_argument->title_query();
     $this->assertEquals(array(), $titles);
     $roles_rid_argument->value = array('test_rid_1');
     $titles = $roles_rid_argument->title_query();
     $this->assertEquals(array('test rid 1'), $titles);
     $roles_rid_argument->value = array('test_rid_1', 'test_rid_2');
     $titles = $roles_rid_argument->title_query();
     $this->assertEquals(array('test rid 1', String::checkPlain('test <strong>rid 2</strong>')), $titles);
 }
コード例 #28
0
ファイル: UrlTest.php プロジェクト: anatalsceo/en-classe
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $map = array();
     $map[] = array('view.frontpage.page_1', array(), array(), '/node');
     $map[] = array('node_view', array('node' => '1'), array(), '/node/1');
     $map[] = array('node_edit', array('node' => '2'), array(), '/node/2/edit');
     $this->map = $map;
     $this->urlGenerator = $this->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $this->urlGenerator->expects($this->any())->method('generateFromRoute')->will($this->returnValueMap($this->map));
     $this->router = $this->getMock('Drupal\\Tests\\Core\\Routing\\TestRouterInterface');
     $container = new ContainerBuilder();
     $container->set('router', $this->router);
     $container->set('url_generator', $this->urlGenerator);
     \Drupal::setContainer($container);
 }
コード例 #29
0
 /**
  * @covers ::set
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Service ID names must be lowercase: Bar
  */
 public function testSetException()
 {
     $container = new ContainerBuilder();
     $class = new BarClass();
     $container->set('Bar', $class);
     $this->assertNotEquals('bar', $class->_serviceId);
 }
コード例 #30
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->editorId = $this->randomMachineName();
     $this->entityTypeId = $this->randomMachineName();
     $this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('editor'));
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
     $this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
     $this->editorPluginManager = $this->getMockBuilder('Drupal\\editor\\Plugin\\EditorManager')->disableOriginalConstructor()->getMock();
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('uuid', $this->uuid);
     $container->set('plugin.manager.editor', $this->editorPluginManager);
     \Drupal::setContainer($container);
 }