/**
  * Tests the action execution.
  *
  * @covers ::execute
  */
 public function testActionExecution()
 {
     $alias = 'about/team';
     $this->aliasStorage->delete(['alias' => $alias])->shouldBeCalledTimes(1);
     $this->action->setContextValue('alias', $alias);
     $this->action->execute();
 }
Пример #2
0
 /**
  * Tests the action execution.
  *
  * @covers ::execute
  */
 public function testActionExecution()
 {
     $this->action->setContextValue('bundle', 'test');
     $this->action->execute();
     $entity = $this->action->getProvidedContext('entity')->getContextValue();
     $this->assertEquals(self::ENTITY_REPLACEMENT, $entity);
 }
 /**
  * Tests the action execution.
  *
  * @covers ::execute
  */
 public function testActionExecution()
 {
     $path = 'node/1';
     $this->aliasStorage->delete(['path' => $path])->shouldBeCalledTimes(1);
     $this->action->setContextValue('path', $path);
     $this->action->execute();
 }
Пример #4
0
 /**
  * Tests the action execution when saving is postponed.
  *
  * @covers ::execute
  */
 public function testActionExecutionPostponed()
 {
     $this->entity->save()->shouldNotBeCalled();
     $this->action->setContextValue('entity', $this->entity->reveal());
     $this->action->execute();
     $this->assertEquals($this->action->autoSaveContext(), ['entity'], 'Action returns the entity context name for auto saving.');
 }
 /**
  * Tests the action execution.
  *
  * @covers ::execute
  */
 public function testActionExecution()
 {
     $list = ['One', 'Two', 'Three'];
     $this->action->setContextValue('list', $list)->setContextValue('item', 'Two');
     $this->action->execute();
     // The second item should be removed from the list.
     $this->assertArrayEquals(['One', 'Three'], array_values($this->action->getContextValue('list')));
 }
Пример #6
0
 /**
  * Tests that the action works if the optional repeat flag is not set.
  *
  * @covers ::execute
  */
 public function testOptionalRepeat()
 {
     $this->action->setContextValue('message', 'test message')->setContextValue('type', 'status');
     $this->action->execute();
     $messages = $this->getMessages('status');
     $this->assertNotNull($messages);
     $this->assertArrayEquals(['test message'], $messages);
 }
Пример #7
0
 /**
  * Tests the action execution when a language is specified.
  *
  * @covers ::execute
  */
 public function testActionExecutionWithLanguage()
 {
     $language = $this->prophesize(LanguageInterface::class);
     $language->getId()->willReturn('en');
     $this->aliasStorage->save('node/1', 'about', 'en')->shouldBeCalledTimes(1);
     $this->action->setContextValue('source', 'node/1')->setContextValue('alias', 'about')->setContextValue('language', $language->reveal());
     $this->action->execute();
 }
Пример #8
0
 /**
  * Tests that a variable can be set to NULL.
  */
 public function testSetToNull()
 {
     // We don't need to set the 'value' context, it is NULL by default.
     $this->action->setContextValue('data', 'original');
     $this->action->execute();
     $this->assertNull($this->action->getContextValue('data'));
     $this->assertSame([], $this->action->autoSaveContext());
 }
 /**
  * Tests the action execution.
  *
  * @covers ::execute
  */
 public function testActionExecution()
 {
     $account = $this->prophesizeEntity(UserInterface::class);
     $mail_type = 'test_mail_type';
     $this->action->setContextValue('user', $account->reveal())->setContextValue('email_type', $mail_type);
     $this->action->execute();
     // To ge the notifications that were sent, we call the _user_mail_notify()
     // with no parameters.
     $notifications = _user_mail_notify();
     $this->assertSame([$mail_type => 1], $notifications);
 }
 /**
  * Tests the action execution with a saved entity.
  *
  * @covers ::execute
  */
 public function testActionExecutionWithSavedEntity()
 {
     // Test that the alias is only saved once.
     $this->aliasStorage->save('test/1', 'about', 'en')->shouldBeCalledTimes(1);
     $entity = $this->getMockEntity();
     $entity->isNew()->willReturn(FALSE)->shouldBeCalledTimes(1);
     // Test that existing entities are not saved again.
     $entity->save()->shouldNotBeCalled();
     $this->action->setContextValue('entity', $entity->reveal())->setContextValue('alias', 'about');
     $this->action->execute();
 }
Пример #11
0
 /**
  * Tests the action execution without Context IP set.
  *
  * Should fallback to the current IP of the request.
  *
  * @covers ::execute
  */
 public function testActionExecutionWithoutContextIP()
 {
     // TEST-NET-1 IPv4.
     $ip = '192.0.2.0';
     $this->request->getClientIp()->willReturn($ip)->shouldBeCalledTimes(1);
     $this->banManager->banIp($ip)->shouldBeCalledTimes(1);
     $this->action->execute();
 }
 /**
  * Tests the use of max operator for 2 input values.
  *
  * @covers ::execute
  */
 public function testMaximumAction()
 {
     $input_1 = mt_rand();
     $input_2 = mt_rand();
     $this->action->setContextValue('input_1', $this->getTypedData('float', $input_1))->setContextValue('operator', $this->getTypedData('string', 'max'))->setContextValue('input_2', $this->getTypedData('float', $input_2));
     $this->action->execute();
     $result = $this->action->getProvidedContext('result')->getContextValue();
     $this->assertEquals(max($input_1, $input_2), $result, "Max calculation correct");
 }
Пример #13
0
 /**
  * Tests the action execution - add non-unique items.
  *
  * @covers ::execute
  */
 public function testActionExecutionNonUnique()
 {
     // Test non-unique.
     $list = ['One', 'Two', 'Three', 'Four'];
     $this->action->setContextValue('list', $list)->setContextValue('item', 'Four')->setContextValue('unique', FALSE)->setContextValue('pos', 'end');
     $this->action->execute();
     // The list should contain five items, with the new item added at the end.
     $this->assertArrayEquals(['One', 'Two', 'Three', 'Four', 'Four'], $this->action->getContextValue('list'));
 }