FlagCountExtensionTest.php in Flag 8.4
File
tests/src/FunctionalJavascript/FlagCountExtensionTest.php
View source
<?php
namespace Drupal\Tests\flag\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class FlagCountExtensionTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'views',
'flag',
'flag_bookmark',
'flag_count',
];
public function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
$flag_service = \Drupal::service('flag');
$bookmark_flag = $flag_service
->getFlagById('bookmark');
$bookmark_flag
->setlinkTypePlugin('count_link');
$bookmark_flag
->save();
}
public function testUi() {
$title = $this
->randomMachineName();
$article = $this
->drupalCreateNode([
'type' => 'article',
'title' => $title,
]);
$auth_user = $this
->drupalCreateUser([
'flag bookmark',
'unflag bookmark',
]);
$assert_session = $this
->assertSession();
$this
->drupalLogin($auth_user);
$this
->drupalGet('node/1');
$element0 = $assert_session
->waitForElementVisible('css', '.flag-bookmark span:contains("[0]")');
$this
->assertNotNull($element0);
$this
->clickLink('Bookmark this');
$element1 = $assert_session
->waitForElementVisible('css', '.flag-bookmark span:contains("[1]")');
$this
->assertNotNull($element1);
$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());
}
}