DashboardTest.php in farmOS 2.x
File
modules/core/ui/dashboard/tests/src/Functional/DashboardTest.php
View source
<?php
namespace Drupal\Tests\farm_ui_dashboard\Functional;
use Drupal\Tests\farm_test\Functional\FarmBrowserTestBase;
class DashboardTest extends FarmBrowserTestBase {
protected $user;
protected static $modules = [
'farm_ui_dashboard',
'farm_ui_dashboard_test',
];
protected function setUp() : void {
parent::setUp();
$this->user = $this
->createUser([
'access farm dashboard',
]);
$this
->drupalLogin($this->user);
}
public function testDashboardBlock() {
$this
->drupalGet('/dashboard');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('This is the dashboard test block.');
}
public function testDashboardView() {
$this
->drupalGet('/dashboard');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextNotContains('User list');
$this
->assertSession()
->pageTextNotContains($this->user
->getAccountName());
$user = $this
->createUser([
'access farm dashboard',
'access user profiles',
]);
$this
->drupalLogin($user);
$this
->drupalGet('/dashboard');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('User list');
$this
->assertSession()
->pageTextContains($user
->getAccountName());
}
}