FlagBookmarkUITest.php in Flag 8.4
File
modules/flag_bookmark/tests/src/FunctionalJavascript/FlagBookmarkUITest.php
View source
<?php
namespace Drupal\Tests\flag_bookmark\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class FlagBookmarkUITest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'views',
'flag',
'flag_bookmark',
];
public function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
}
public function testUi() {
$article = $this
->drupalCreateNode([
'type' => 'article',
]);
$auth_user = $this
->drupalCreateUser([
'flag bookmark',
'unflag bookmark',
]);
$assert_session = $this
->assertSession();
$this
->drupalLogin($auth_user);
$this
->drupalGet('node/1');
$this
->clickLink('Bookmark this');
$bookmark_link = $assert_session
->waitForLink('Remove bookmark');
$this
->assertNotNull($bookmark_link, 'Remove bookmark is availble on the page.');
$this
->drupalGet('bookmarks');
$assert_session
->pageTextContains($article
->getTitle());
}
public function testUiBulkDelete() {
$articles[] = $this
->drupalCreateNode([
'type' => 'article',
]);
$articles[] = $this
->drupalCreateNode([
'type' => 'article',
]);
$admin_user = $this
->drupalCreateUser([
'flag bookmark',
'unflag bookmark',
'administer flaggings',
]);
$this
->drupalLogin($admin_user);
$flag_service = \Drupal::service('flag');
$bookmark_flag = $flag_service
->getFlagById('bookmark');
$flag_service
->flag($bookmark_flag, $articles[0]);
$flag_service
->flag($bookmark_flag, $articles[1]);
$assert_session = $this
->assertSession();
$this
->drupalGet('bookmarks');
$page = $this
->getSession()
->getPage();
$assert_session
->pageTextContains('Delete flagging');
$assert_session
->pageTextContains($articles[0]
->label());
$assert_session
->pageTextContains($articles[1]
->label());
$page
->find('css', 'input[title="Select all rows in this table"]')
->check();
$page
->pressButton('Apply to selected items');
$empty_form = $assert_session
->waitForElementVisible('css', "form:contains('No bookmarks available.')");
$this
->assertNotNull($empty_form, 'Flagging form is empty.');
$assert_session
->pageTextNotContains($articles[0]
->label());
$assert_session
->pageTextNotContains($articles[1]
->label());
}
}