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


PHP Tests\UnitTestCase类代码示例

本文整理汇总了PHP中Drupal\Tests\UnitTestCase的典型用法代码示例。如果您正苦于以下问题:PHP UnitTestCase类的具体用法?PHP UnitTestCase怎么用?PHP UnitTestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $configuration = ['test_foo_settings' => ['collection' => 'test-23', 'cache_backend_class' => '\\Drupal\\Tests\\Component\\FileCache\\StaticFileCacheBackend', 'cache_backend_configuration' => ['bin' => 'dog']]];
     FileCacheFactory::setConfiguration($configuration);
     FileCacheFactory::setPrefix('prefix');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:FileCacheFactoryTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Mock a Discovery object to replace AnnotationClassDiscovery.
     $this->discovery = $this->getMock('Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface');
     $this->discovery->expects($this->any())->method('getDefinitions')->will($this->returnValue($this->definitions));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:DevelGenerateManagerTest.php

示例3: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->requestStack = new RequestStack();
     $this->pathProcessor = $this->getMock('Drupal\\Core\\PathProcessor\\OutboundPathProcessorInterface');
     $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:10,代码来源:UnroutedUrlAssemblerTest.php

示例4: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->key = Crypt::randomBytesBase64(55);
     $this->state = $this->getMock('Drupal\\Core\\State\\StateInterface');
     $this->privateKey = new PrivateKey($this->state);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:PrivateKeyTest.php

示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->migration = $this->prophesize(MigrationInterface::class);
     $this->storage = $this->prophesize(EntityStorageInterface::class);
     $this->entityManager = $this->prophesize(EntityManagerInterface::class);
 }
开发者ID:318io,项目名称:318-io,代码行数:10,代码来源:EntityContentBaseTest.php

示例6: setUp

  /**
   * Creates a new processor object for use in the tests.
   */
  protected function setUp() {
    parent::setUp();

    // Create a mock for the URL to be returned.
    $url = $this->getMockBuilder('Drupal\Core\Url')
      ->disableOriginalConstructor()
      ->getMock();
    $url->expects($this->any())
      ->method('toString')
      ->will($this->returnValue('http://www.example.com/node/example'));

    // Mock the data source of the indexer to return the mocked url object.
    $datasource = $this->getMock('Drupal\search_api\Datasource\DatasourceInterface');
    $datasource->expects($this->any())
      ->method('getItemUrl')
      ->withAnyParameters()
      ->will($this->returnValue($url));

    // Create a mock for the index to return the datasource mock.
    /** @var \Drupal\search_api\IndexInterface $index */
    $index = $this->index = $this->getMock('Drupal\search_api\IndexInterface');
    $this->index->expects($this->any())
      ->method('getDatasource')
      ->with('entity:node')
      ->will($this->returnValue($datasource));

    // Create the tested processor and set the mocked indexer.
    $this->processor = new AddURL(array(), 'add_url', array());
    $this->processor->setIndex($index);
    /** @var \Drupal\Core\StringTranslation\TranslationInterface $translation */
    $translation = $this->getStringTranslationStub();
    $this->processor->setStringTranslation($translation);
  }
开发者ID:jkyto,项目名称:agolf,代码行数:36,代码来源:AddURLTest.php

示例7: setUp

 /**
  * {@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');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:ViewsBlockTest.php

示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->accessManager = $this->getMock('\\Drupal\\Core\\Access\\AccessManagerInterface');
     $this->currentUser = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
     $this->defaultMenuTreeManipulators = new DefaultMenuLinkTreeManipulators($this->accessManager, $this->currentUser);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:DefaultMenuLinkTreeManipulatorsTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     // Set up three memory backends to be used in the chain.
     $this->firstBackend = new MemoryBackend('foo');
     $this->secondBackend = new MemoryBackend('bar');
     $this->thirdBackend = new MemoryBackend('baz');
     // Set an initial fixed dataset for all testing. The next three data
     // collections will test two edge cases (last backend has the data, and
     // first backend has the data) and will test a normal use case (middle
     // backend has the data). We should have a complete unit test with those.
     // Note that in all cases, when the same key is set on more than one
     // backend, the values are voluntarily different, this ensures in which
     // backend we actually fetched the key when doing get calls.
     // Set a key present on all backends (for delete).
     $this->firstBackend->set('t123', 1231);
     $this->secondBackend->set('t123', 1232);
     $this->thirdBackend->set('t123', 1233);
     // Set a key present on the second and the third (for get), those two will
     // be different, this will ensure from where we get the key.
     $this->secondBackend->set('t23', 232);
     $this->thirdBackend->set('t23', 233);
     // Set a key on only the third, we will ensure propagation using this one.
     $this->thirdBackend->set('t3', 33);
     // Create the chain.
     $this->chain = new BackendChain('foobarbaz');
     $this->chain->appendBackend($this->firstBackend)->appendBackend($this->secondBackend)->appendBackend($this->thirdBackend);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:28,代码来源:BackendChainImplementationUnitTest.php

示例10: setUp

 /**
  * Creates a new processor object for use in the tests.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->processor = new RoleFilter(array(), 'role_filter', array());
     /** @var \Drupal\search_api\IndexInterface $index */
     $index = $this->getMock('Drupal\\search_api\\IndexInterface');
     $node_datasource = $this->getMock('Drupal\\search_api\\Datasource\\DatasourceInterface');
     $node_datasource->expects($this->any())->method('getEntityTypeId')->will($this->returnValue('node'));
     /** @var \Drupal\search_api\Datasource\DatasourceInterface $node_datasource */
     $user_datasource = $this->getMock('Drupal\\search_api\\Datasource\\DatasourceInterface');
     $user_datasource->expects($this->any())->method('getEntityTypeId')->will($this->returnValue('user'));
     /** @var \Drupal\search_api\Datasource\DatasourceInterface $user_datasource */
     $item = Utility::createItem($index, Utility::createCombinedId('entity:node', '1:en'), $node_datasource);
     $node = $this->getMockBuilder('Drupal\\Tests\\search_api\\TestNodeInterface')->disableOriginalConstructor()->getMock();
     /** @var \Drupal\node\NodeInterface $node */
     $item->setOriginalObject(EntityAdapter::createFromEntity($node));
     $this->items[$item->getId()] = $item;
     $item = Utility::createItem($index, Utility::createCombinedId('entity:user', '1:en'), $user_datasource);
     $account1 = $this->getMockBuilder('Drupal\\Tests\\search_api\\TestUserInterface')->disableOriginalConstructor()->getMock();
     $account1->expects($this->any())->method('getRoles')->will($this->returnValue(array('authenticated' => 'authenticated', 'editor' => 'editor')));
     /** @var \Drupal\user\UserInterface $account1 */
     $item->setOriginalObject(EntityAdapter::createFromEntity($account1));
     $this->items[$item->getId()] = $item;
     $item = Utility::createItem($index, Utility::createCombinedId('entity:user', '2:en'), $user_datasource);
     $account2 = $this->getMockBuilder('Drupal\\Tests\\search_api\\TestUserInterface')->disableOriginalConstructor()->getMock();
     $account2->expects($this->any())->method('getRoles')->will($this->returnValue(array('authenticated' => 'authenticated')));
     /** @var \Drupal\user\UserInterface $account2 */
     $item->setOriginalObject(EntityAdapter::createFromEntity($account2));
     $this->items[$item->getId()] = $item;
 }
开发者ID:curveagency,项目名称:intranet,代码行数:33,代码来源:RoleFilterTest.php

示例11: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->formBuilder = $this->getMock('Drupal\\Core\\Form\\FormBuilderInterface');
     $this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityFormBuilder = new EntityFormBuilder($this->entityManager, $this->formBuilder);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:EntityFormBuilderTest.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     $this->redirectDestination = $this->getMock(RedirectDestinationInterface::class);
     $this->stringTranslation = $this->getStringTranslationStub();
     $this->sut = new FixedRatesOperationsProvider($this->stringTranslation, $this->redirectDestination);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:7,代码来源:FixedRatesOperationsProviderTest.php

示例13: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityTypeId = 'workspace';
     $first_machine_name = $this->randomMachineName();
     $second_machine_name = $this->randomMachineName();
     $this->values = [['machine_name' => $first_machine_name], ['machine_name' => $second_machine_name]];
     $this->entityType = $this->getMock('Drupal\\multiversion\\Entity\\WorkspaceInterface');
     $this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->cacheRender = $this->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
     $this->requestStack = $this->getMock('Symfony\\Component\\HttpFoundation\\RequestStack');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('request_stack', $this->requestStack);
     $container->set('cache.render', $this->cacheRender);
     \Drupal::setContainer($container);
     foreach ($this->values as $value) {
         $entity = $this->getMockBuilder('Drupal\\multiversion\\Entity\\Workspace')->disableOriginalConstructor()->getMock();
         $entity->expects($this->any())->method('create')->with($value)->will($this->returnValue($this->entityType));
         $this->entities[] = $entity;
     }
     $this->workspaceNegotiators[] = array($this->getMock('Drupal\\multiversion\\Workspace\\DefaultWorkspaceNegotiator'));
     $this->workspaceNegotiators[] = array($this->getMock('Drupal\\multiversion\\Workspace\\SessionWorkspaceNegotiator'));
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:28,代码来源:WorkspaceManagerTest.php

示例14: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->cacheTagsInvalidator = $this->getMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
     $this->libraryDiscoveryCollector = $this->getMockBuilder('Drupal\\Core\\Asset\\LibraryDiscoveryCollector')->disableOriginalConstructor()->getMock();
     $this->libraryDiscovery = new LibraryDiscovery($this->libraryDiscoveryCollector, $this->cacheTagsInvalidator);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:LibraryDiscoveryTest.php

示例15: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->route = new Route('test');
     $this->accessManager = $this->getMock('Drupal\\Core\\Access\\AccessManagerInterface');
     $this->currentUser = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:AccessAwareRouterTest.php


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