• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Tests\UnitTestCase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $settings = [];
     $settings['extension_discovery_scan_tests'] = TRUE;
     new Settings($settings);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:UpdateRegistryTest.php


示例17: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     new Settings(array('hash_salt' => 'test'));
     // The mocked super user account, with the same roles as Account 2.
     $this->account1 = $this->getMockBuilder('Drupal\\user\\Entity\\User')->disableOriginalConstructor()->setMethods(array('getRoles', 'id'))->getMock();
     $this->account1->expects($this->any())->method('id')->willReturn(1);
     $this->account1->expects($this->never())->method('getRoles');
     // Account 2: 'administrator' and 'authenticated' roles.
     $roles_1 = array('administrator', 'authenticated');
     $this->account2 = $this->getMockBuilder('Drupal\\user\\Entity\\User')->disableOriginalConstructor()->setMethods(array('getRoles', 'id'))->getMock();
     $this->account2->expects($this->any())->method('getRoles')->will($this->returnValue($roles_1));
     $this->account2->expects($this->any())->method('id')->willReturn(2);
     // Account 3: 'authenticated' and 'administrator' roles (different order).
     $roles_3 = array('authenticated', 'administrator');
     $this->account3 = $this->getMockBuilder('Drupal\\user\\Entity\\User')->disableOriginalConstructor()->setMethods(array('getRoles', 'id'))->getMock();
     $this->account3->expects($this->any())->method('getRoles')->will($this->returnValue($roles_3));
     $this->account3->expects($this->any())->method('id')->willReturn(3);
     // Updated account 2: now also 'editor' role.
     $roles_2_updated = array('editor', 'administrator', 'authenticated');
     $this->account2Updated = $this->getMockBuilder('Drupal\\user\\Entity\\User')->disableOriginalConstructor()->setMethods(array('getRoles', 'id'))->getMock();
     $this->account2Updated->expects($this->any())->method('getRoles')->will($this->returnValue($roles_2_updated));
     $this->account2Updated->expects($this->any())->method('id')->willReturn(2);
     // Mocked private key + cache services.
     $random = Crypt::randomBytesBase64(55);
     $this->privateKey = $this->getMockBuilder('Drupal\\Core\\PrivateKey')->disableOriginalConstructor()->setMethods(array('get'))->getMock();
     $this->privateKey->expects($this->any())->method('get')->will($this->returnValue($random));
     $this->cache = $this->getMockBuilder('Drupal\\Core\\Cache\\CacheBackendInterface')->disableOriginalConstructor()->getMock();
     $this->staticCache = $this->getMockBuilder('Drupal\\Core\\Cache\\CacheBackendInterface')->disableOriginalConstructor()->getMock();
     $this->permissionsHash = new PermissionsHashGenerator($this->privateKey, $this->cache, $this->staticCache);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:34,代码来源:PermissionsHashGeneratorTest.php


示例18: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $storage = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockArraySessionStorage')->setMethods(NULL)->getMock();
     $this->session = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\Session\\Session')->setConstructorArgs(array($storage))->setMethods(NULL)->getMock();
     $this->session->start();
 }
开发者ID:pulibrary,项目名称:recap,代码行数:10,代码来源:CasProxyHelperTest.php


示例19: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->requestStack = $this->getMock('\\Symfony\\Component\\HttpFoundation\\RequestStack');
     $this->connection = $this->getMockBuilder('\\Drupal\\Core\\Database\\Connection')->disableOriginalConstructor()->getMock();
     $this->casHelper = $this->getMockBuilder('\\Drupal\\cas\\Service\\CasHelper')->disableOriginalConstructor()->getMock();
 }
开发者ID:pulibrary,项目名称:recap,代码行数:10,代码来源:ProxyCallbackControllerTest.php


示例20: setUp

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->aliasProcessor = $this->getMockBuilder('Drupal\Core\PathProcessor\PathProcessorAlias')
      ->disableOriginalConstructor()
      ->getMock();

    $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
    $this->languageManager->expects($this->any())
      ->method('getCurrentLanguage')
      ->willReturn(new Language(Language::$defaultValues));

    $this->pathValidator = $this->getMock('Drupal\Core\Path\PathValidatorInterface');

    $this->subPathautoSettings = $this->getMock('Drupal\Core\Config\ConfigBase');

    $this->configFactory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
    $this->configFactory->expects($this->any())
      ->method('get')
      ->with('subpathauto.settings')
      ->willReturn($this->subPathautoSettings);

    $this->sut = new PathProcessor($this->aliasProcessor, $this->languageManager, $this->configFactory);
    $this->sut->setPathValidator($this->pathValidator);
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:28,代码来源:SubPathautoTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Unit\MigrateSqlSourceTestCase类代码示例发布时间:2022-05-23
下一篇:
PHP Tests\TaxonomyTestBase类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap