/**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->condition = $this->conditionManager->createInstance('rules_path_has_alias');
     $this->englishLanguage = $this->prophesize(LanguageInterface::class);
     $this->englishLanguage->getId()->willReturn('en');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->action = $this->actionManager->createInstance('rules_system_message');
     // Clear the statically stored messages before every test run.
     $this->clearMessages();
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Mock a logger.
     $this->logger = $this->prophesize(LoggerInterface::class);
     // Mock the logger service, make it return our mocked logger, and register
     // it in the container.
     $this->loggerFactory = $this->prophesize(LoggerChannelFactoryInterface::class);
     $this->loggerFactory->get('rules')->willReturn($this->logger->reveal());
     $this->container->set('logger.factory', $this->loggerFactory->reveal());
     // Mock a parameter bag.
     $this->parameterBag = $this->prophesize(ParameterBag::class);
     // Mock a request, and set our mocked parameter bag as it attributes
     // property.
     $this->currentRequest = $this->prophesize(Request::class);
     $this->currentRequest->attributes = $this->parameterBag->reveal();
     // Mock the request stack, make it return our mocked request when the
     // current request is requested, and register it in the container.
     $this->requestStack = $this->prophesize(RequestStack::class);
     $this->requestStack->getCurrentRequest()->willReturn($this->currentRequest);
     $this->container->set('request_stack', $this->requestStack->reveal());
     // Mock the current path stack.
     $this->currentPathStack = $this->prophesize(CurrentPathStack::class);
     $this->container->set('path.current', $this->currentPathStack->reveal());
     // Instantiate the redirect action.
     $this->action = $this->actionManager->createInstance('rules_page_redirect');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->aliasStorage = $this->prophesize(AliasStorageInterface::class);
     $this->container->set('path.alias_storage', $this->aliasStorage->reveal());
     $this->action = $this->actionManager->createInstance('rules_path_alias_delete_by_alias');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('user');
     // Some of our plugins assume sessions exist:
     $session_manager = $this->prophesize(SessionManagerInterface::class);
     $this->container->set('session_manager', $session_manager->reveal());
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->logger = $this->prophesize(LoggerInterface::class);
     $this->mailManager = $this->prophesize(MailManagerInterface::class);
     $this->container->set('logger.factory', $this->logger->reveal());
     $this->container->set('plugin.manager.mail', $this->mailManager->reveal());
     $this->action = $this->actionManager->createInstance('rules_send_email');
 }
Exemple #7
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // We need the ban module.
     $this->enableModule('ban');
     $this->banManager = $this->prophesize(BanIpManagerInterface::class);
     $this->container->set('ban.ip_manager', $this->banManager->reveal());
     $this->request = $this->prophesize(Request::class);
     $this->container->set('request', $this->request->reveal());
     $this->action = $this->actionManager->createInstance('rules_ban_ip');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->logger = $this->prophesize(LoggerInterface::class);
     $logger_factory = $this->prophesize(LoggerChannelFactoryInterface::class);
     $logger_factory->get('rules')->willReturn($this->logger->reveal());
     $this->mailManager = $this->prophesize(MailManagerInterface::class);
     // @todo this is wrong, the logger is no factory.
     $this->container->set('logger.factory', $logger_factory->reveal());
     $this->container->set('plugin.manager.mail', $this->mailManager->reveal());
     $this->action = $this->actionManager->createInstance('rules_send_email');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setup();
     require_once $this->root . '/core/includes/entity.inc';
     $this->namespaces['Drupal\\Core\\Entity'] = $this->root . '/core/lib/Drupal/Core/Entity';
     $language = $this->prophesize(LanguageInterface::class);
     $language->getId()->willReturn('en');
     $this->languageManager = $this->prophesize(LanguageManagerInterface::class);
     $this->languageManager->getCurrentLanguage()->willReturn($language->reveal());
     $this->languageManager->getLanguages()->willReturn([$language->reveal()]);
     // We need to support multiple entity types, including a test type:
     $type_info = ['test' => ['id' => 'test', 'label' => 'Test', 'entity_keys' => ['bundle' => 'bundle']], 'user' => ['id' => 'user', 'label' => 'Test User', 'entity_keys' => ['bundle' => 'user']], 'node' => ['id' => 'node', 'label' => 'Test Node', 'entity_keys' => ['bundle' => 'dummy']]];
     $type_array = [];
     foreach ($type_info as $type => $info) {
         $entity_type = new ContentEntityType($info);
         $type_array[$type] = $entity_type;
         $this->entityTypeManager->getDefinition($type)->willReturn($entity_type);
         $this->entityManager->getDefinition($type)->willReturn($entity_type);
     }
     // We need a user_role mock as well.
     $role_entity_info = ['id' => 'user_role', 'label' => 'Test Role'];
     $role_type = new ConfigEntityType($role_entity_info);
     $type_array['user_role'] = $role_type;
     $this->entityTypeManager->getDefinitions()->willReturn($type_array);
     $this->entityManager->getDefinitions()->willReturn($type_array);
     $this->entityAccess = $this->prophesize(EntityAccessControlHandlerInterface::class);
     $this->entityTypeManager->getAccessControlHandler(Argument::any())->willReturn($this->entityAccess->reveal());
     // The base field definitions for our test entity aren't used, and would
     // require additional mocking. It doesn't appear that any of our tests rely
     // on this for any other entity type that we are mocking.
     $this->entityFieldManager->getBaseFieldDefinitions(Argument::any())->willReturn([]);
     $this->entityManager->getBaseFieldDefinitions(Argument::any())->willReturn([]);
     // Return some dummy bundle information for now, so that the entity manager
     // does not call out to the config entity system to get bundle information.
     $this->entityTypeBundleInfo->getBundleInfo(Argument::any())->willReturn(['test' => ['label' => 'Test']]);
     $this->entityManager->getBundleInfo(Argument::any())->willReturn(['test' => ['label' => 'Test']]);
     $this->moduleHandler->getImplementations('entity_type_build')->willReturn([]);
     $this->fieldTypeManager = new FieldTypePluginManager($this->namespaces, $this->cacheBackend, $this->moduleHandler->reveal(), $this->typedDataManager);
     $this->container->set('plugin.manager.field.field_type', $this->fieldTypeManager);
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setup();
     require_once $this->root . '/core/includes/entity.inc';
     $this->namespaces['Drupal\\Core\\Entity'] = $this->root . '/core/lib/Drupal/Core/Entity';
     $language = $this->prophesize(LanguageInterface::class);
     $language->getId()->willReturn('en');
     $this->languageManager = $this->prophesize(LanguageManagerInterface::class);
     $this->languageManager->getCurrentLanguage()->willReturn($language->reveal());
     $this->languageManager->getLanguages()->willReturn([$language->reveal()]);
     $entityType = new ContentEntityType(['id' => 'test', 'label' => 'Test', 'entity_keys' => ['bundle' => 'bundle']]);
     $this->entityManager->getDefinitions()->willReturn(['test' => $entityType]);
     $this->entityAccess = $this->prophesize(EntityAccessControlHandlerInterface::class);
     $this->entityManager->getAccessControlHandler(Argument::any())->willReturn($this->entityAccess->reveal());
     // The base field definitions for our test entity aren't used, and would
     // require additional mocking.
     $this->entityManager->getBaseFieldDefinitions('test')->willReturn([]);
     // Return some dummy bundle information for now, so that the entity manager
     // does not call out to the config entity system to get bundle information.
     $this->entityManager->getBundleInfo(Argument::any())->willReturn(['test' => ['label' => 'Test']]);
     $this->moduleHandler->getImplementations('entity_type_build')->willReturn([]);
 }
Exemple #11
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->condition = $this->conditionManager->createInstance('rules_list_contains');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->action = $this->actionManager->createInstance('rules_list_item_remove');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->action = $this->actionManager->createInstance('rules_data_calculate_value');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->condition = $this->conditionManager->createInstance('rules_data_is_empty');
 }