Example #1
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('user');
     $this->sessionManager = $this->prophesize(SessionManagerInterface::class);
     $this->container->set('session_manager', $this->sessionManager->reveal());
     $this->action = $this->actionManager->createInstance('rules_user_block');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Prepare mocked AliasStorageInterface.
     $this->aliasStorage = $this->prophesize(AliasStorageInterface::class);
     $this->container->set('path.alias_storage', $this->aliasStorage->reveal());
     // Instantiate the action we are testing.
     $this->action = $this->actionManager->createInstance('rules_entity_path_alias_create:entity:test');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Prepare some mocked bundle field definitions. This is needed because
     // EntityCreateDeriver adds required contexts for required fields, and
     // assumes that the bundle field is required.
     $bundle_field_definition = $this->prophesize(BaseFieldDefinition::class);
     $bundle_field_definition_optional = $this->prophesize(BaseFieldDefinition::class);
     $bundle_field_definition_required = $this->prophesize(BaseFieldDefinition::class);
     $property_definition = $this->prophesize(DataDefinitionInterface::class);
     $property_definition->getDataType()->willReturn('string');
     $item_definition = $this->prophesize(FieldItemDataDefinition::class);
     $item_definition->getPropertyDefinition(Argument::any())->willReturn($property_definition->reveal());
     $item_definition->getMainPropertyName()->willReturn('value');
     // The next methods are mocked because EntityCreateDeriver executes them,
     // and the mocked field definition is instantiated without the necessary
     // information.
     $bundle_field_definition->getItemDefinition()->willReturn($item_definition->reveal());
     $bundle_field_definition->getCardinality()->willReturn(1)->shouldBeCalledTimes(1);
     $bundle_field_definition->getType()->willReturn('string');
     $bundle_field_definition->getLabel()->willReturn('Bundle')->shouldBeCalledTimes(1);
     $bundle_field_definition->getDescription()->willReturn('Bundle mock description')->shouldBeCalledTimes(1);
     $bundle_field_definition_required->getItemDefinition()->willReturn($item_definition->reveal());
     $bundle_field_definition_required->getCardinality()->willReturn(1)->shouldBeCalledTimes(1);
     $bundle_field_definition_required->getType()->willReturn('string');
     $bundle_field_definition_required->getLabel()->willReturn('Required field')->shouldBeCalledTimes(1);
     $bundle_field_definition_required->getDescription()->willReturn('Required field mock description')->shouldBeCalledTimes(1);
     $bundle_field_definition_required->isRequired()->willReturn(TRUE)->shouldBeCalledTimes(1);
     $bundle_field_definition_optional->isRequired()->willReturn(FALSE)->shouldBeCalledTimes(1);
     // Prepare mocked entity storage.
     $entity_type_storage = $this->prophesize(EntityStorageBase::class);
     $entity_type_storage->create(['bundle' => 'test', 'field_required' => NULL])->willReturn(self::ENTITY_REPLACEMENT);
     // Return the mocked storage controller.
     $this->entityTypeManager->getStorage('test')->willReturn($entity_type_storage->reveal());
     // Return a mocked list of base fields definitions.
     $this->entityFieldManager->getBaseFieldDefinitions('test')->willReturn(['bundle' => $bundle_field_definition->reveal(), 'field_required' => $bundle_field_definition_required->reveal(), 'field_optional' => $bundle_field_definition_optional->reveal()]);
     // Instantiate the action we are testing.
     $this->action = $this->actionManager->createInstance('rules_entity_create:test');
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Prepare mocked bundle field definition. This is needed because
     // EntityCreateDeriver adds required contexts for required fields, and
     // assumes that the bundle field is required.
     $bundle_field_definition = $this->prophesize(BaseFieldDefinition::class);
     // The next methods are mocked because EntityCreateDeriver executes them,
     // and the mocked field definition is instantiated without the necessary
     // information.
     $bundle_field_definition->getCardinality()->willReturn(1)->shouldBeCalledTimes(1);
     $bundle_field_definition->getType()->willReturn('string')->shouldBeCalledTimes(1);
     $bundle_field_definition->getLabel()->willReturn('Bundle')->shouldBeCalledTimes(1);
     $bundle_field_definition->getDescription()->willReturn('Bundle mock description')->shouldBeCalledTimes(1);
     // Prepare mocked entity storage.
     $entity_type_storage = $this->prophesize(EntityStorageBase::class);
     $entity_type_storage->create(['bundle' => 'test'])->willReturn(self::ENTITY_REPLACEMENT);
     // Return the mocked storage controller.
     $this->entityTypeManager->getStorage('test')->willReturn($entity_type_storage->reveal());
     // Return a mocked list of base fields definitions.
     $this->entityFieldManager->getBaseFieldDefinitions('test')->willReturn(['bundle' => $bundle_field_definition->reveal()]);
     // Instantiate the action we are testing.
     $this->action = $this->actionManager->createInstance('rules_entity_create:entity:test');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('user');
     $this->action = $this->actionManager->createInstance('rules_user_role_add');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->action = $this->actionManager->createInstance('rules_entity_fetch_by_field');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->condition = $this->conditionManager->createInstance('rules_entity_is_of_bundle');
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->moduleHandler->getModuleDirectories()->willReturn(['rules' => __DIR__ . '/../../../..']);
     $this->eventManager = new RulesEventManager($this->moduleHandler->reveal());
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->condition = $this->conditionManager->createInstance('rules_entity_has_field');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('node');
     $this->condition = $this->conditionManager->createInstance('rules_node_is_sticky');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('user');
     $this->condition = $this->conditionManager->createInstance('rules_entity_field_access');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('user');
     $this->condition = $this->conditionManager->createInstance('rules_user_is_blocked');
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->entity = $this->prophesizeEntity(EntityInterface::class);
     $this->action = $this->actionManager->createInstance('rules_entity_save');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('user');
     $this->action = $this->actionManager->createInstance('rules_send_account_email');
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->enableModule('node');
 }