MessageNotifyUiTest.php in Message UI 8        
                          
                  
                        
  
  
  
  
  
File
  tests/src/Functional/MessageNotifyUiTest.php
  
    View source  
  <?php
namespace Drupal\Tests\message_ui\Functional;
class MessageNotifyUiTest extends AbstractTestMessageUi {
  
  public static $modules = [
    'message',
    'message_notify_ui',
  ];
  
  public function setUp() {
    parent::setUp();
    $this->account = $this
      ->drupalCreateUser([
      'send message through the ui',
      'overview messages',
    ]);
    
    $this
      ->createMessageTemplate('foo', 'Dummy test', 'Example text.', [
      'Dummy message',
    ]);
  }
  
  public function testMessageNotifyUi() {
    
    $this
      ->drupalLogin($this->account);
    
    $message = $this->container
      ->get('entity_type.manager')
      ->getStorage('message')
      ->create([
      'template' => 'foo',
    ]);
    $message
      ->save();
    
    $edit = [
      'use_custom' => TRUE,
      'email' => 'foo@gmail.com',
    ];
    $this
      ->drupalPostForm('message/' . $message
      ->id() . '/notify', $edit, t('Notify'));
    $this
      ->assertSession()
      ->pageTextContains('The email sent successfully.');
  }
}