RrssbTest.php in Ridiculously Responsive Social Sharing Buttons 8.2        
                          
                  
                        
  
  
  
  
  
File
  tests/src/Functional/RrssbTest.php
  
    View source  
  <?php
namespace Drupal\Tests\rrssb\Functional;
use Drupal\Tests\BrowserTestBase;
class RrssbTest extends BrowserTestBase {
  
  protected static $modules = [
    'node',
    'field_ui',
    'rrssb',
  ];
  
  protected $defaultTheme = 'stark';
  
  protected function setUp() : void {
    parent::setUp();
    $this
      ->drupalCreateContentType([
      'type' => 'article',
      'name' => 'Article',
    ]);
  }
  
  public function testEntityExtraField() {
    
    $user = $this
      ->drupalCreateUser([
      'access administration pages',
      'administer content types',
      'administer nodes',
      'administer node display',
      'view the administration theme',
      'administer rrssb',
    ]);
    $this
      ->drupalLogin($user);
    $node = $this
      ->drupalCreateNode([
      'type' => 'article',
    ]);
    $assert = $this
      ->assertSession();
    
    $edit = [
      'button_set' => 'default',
    ];
    $this
      ->drupalGet('admin/structure/types/manage/article');
    $this
      ->submitForm($edit, 'Save content type');
    
    $this
      ->drupalGet('admin/structure/types/manage/article/display');
    $this
      ->drupalGet('admin/config/content/rrssb');
    $this
      ->drupalGet('admin/config/content/rrssb/default');
    
    $this
      ->drupalGet($node
      ->toUrl());
    $share_url = "https://www.facebook.com/sharer/sharer.php?u=" . urlencode($node
      ->toUrl('canonical', [
      'absolute' => TRUE,
    ])
      ->toString());
    $assert
      ->elementTextContains('css', 'ul.rrssb-buttons li.rrssb-facebook a[href="' . $share_url . '"]', 'Facebook');
  }
}