SharethisViewsPluginTest.php in ShareThis 8.2
File
tests/src/Functional/Views/SharethisViewsPluginTest.php
View source
<?php
namespace Drupal\Tests\sharethis\Functional\Views;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
use Drupal\Tests\views\Functional\ViewTestBase;
class SharethisViewsPluginTest extends ViewTestBase {
protected $defaultTheme = 'classy';
protected $privilegedUser;
public static $modules = [
'node',
'system_test',
'views',
'user',
'sharethis',
'sharethis_test_views',
];
public static $testViews = [
'test_sharethis',
];
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this->privilegedUser = $this
->drupalCreateUser([
'administer site configuration',
'access administration pages',
]);
$this
->drupalLogin($this->privilegedUser);
ViewTestData::createTestViews(get_class($this), [
'sharethis_test_views',
]);
}
public function testHandlers() {
$this
->drupalCreateNode();
$this
->drupalCreateNode();
$view = Views::getView('test_sharethis');
$view
->setDisplay('page_1');
$this
->executeView($view);
$this
->assertEqual(count($view->result), 2);
$this
->drupalGet('test-sharethis');
$result = $this
->xpath('//div[@class=:class]', [
':class' => 'sharethis-wrapper',
]);
$this
->assertEqual(count($result), 2, 'Sharethis links found');
}
}