public function setUp()
 {
     $this->account = $this->prophesize(AccountInterface::class);
     $this->contextHandler = $this->prophesize(ContextHandlerInterface::class);
     $this->uuidGenerator = $this->prophesize(UuidInterface::class);
     $this->token = $this->prophesize(Token::class);
     $this->blockManager = $this->prophesize(BlockManager::class);
     $this->conditionManager = $this->prophesize(ConditionManager::class);
     $this->builderManager = $this->prophesize(DisplayBuilderManagerInterface::class);
     $this->layoutManager = $this->prophesize(LayoutPluginManagerInterface::class);
     $this->layout = $this->prophesize(LayoutInterface::class);
     $this->layoutManager->createInstance(Argument::type('string'), Argument::type('array'))->willReturn($this->layout->reveal());
     $this->variant = new PanelsDisplayVariant([], '', [], $this->contextHandler->reveal(), $this->account->reveal(), $this->uuidGenerator->reveal(), $this->token->reveal(), $this->blockManager->reveal(), $this->conditionManager->reveal(), $this->builderManager->reveal(), $this->layoutManager->reveal());
 }
Пример #2
0
 /**
  * Tests that negating a condition works.
  */
 public function testNegation()
 {
     $this->trueCondition->getContextDefinitions()->willReturn([]);
     $this->trueCondition->refineContextDefinitions()->shouldBeCalledTimes(1);
     $this->trueCondition->getProvidedContextDefinitions()->willReturn([])->shouldBeCalledTimes(1);
     $this->conditionManager->createInstance('test_condition', ['negate' => TRUE])->willReturn($this->trueCondition->reveal())->shouldBeCalledTimes(1);
     // Create a condition which is negated.
     $condition_expression = new RulesCondition(['condition_id' => 'test_condition', 'negate' => TRUE], '', [], $this->conditionManager->reveal(), $this->processorManager->reveal());
     $this->assertFalse($condition_expression->execute());
 }
Пример #3
0
 /**
  * Tests that context values get data processed with processor mappings.
  */
 public function testDataProcessor()
 {
     $condition = new RulesCondition(['condition_id' => 'test_condition'] + ContextConfig::create()->process('test', 'foo', [])->toArray(), '', [], $this->conditionManager->reveal(), $this->processorManager->reveal());
     // Build some mocked context and definitions for our mock condition.
     $context = $this->prophesize(ContextInterface::class);
     $condition->setContext('test', $context->reveal());
     $this->trueCondition->getContextDefinitions()->willReturn(['test' => $this->prophesize(ContextDefinitionInterface::class)->reveal()])->shouldBeCalledTimes(2);
     $this->trueCondition->getProvidedContextDefinitions()->willReturn([])->shouldBeCalledTimes(1);
     // Mock some original old value that will be replaced by the data processor.
     $this->trueCondition->getContextValue('test')->willReturn('old_value')->shouldBeCalledTimes(1);
     // The outcome of the data processor needs to get set on the condition.
     $this->trueCondition->setContextValue('test', 'new_value')->shouldBeCalledTimes(1);
     $this->trueCondition->refineContextDefinitions()->shouldBeCalledTimes(1);
     $this->conditionManager->createInstance('test_condition', ['negate' => FALSE])->willReturn($this->trueCondition->reveal())->shouldBeCalledTimes(1);
     $this->conditionManager->createInstance('test_condition')->willReturn($this->trueCondition->reveal())->shouldBeCalledTimes(1);
     $data_processor = $this->prophesize(DataProcessorInterface::class);
     $data_processor->process('old_value', Argument::any())->willReturn('new_value')->shouldBeCalledTimes(1);
     $this->processorManager->createInstance('foo', [])->willReturn($data_processor->reveal())->shouldBeCalledTimes(1);
     $this->assertTrue($condition->execute());
 }