TrainingEditInterfaceTest.php in Opigno Learning path 3.x
File
tests/src/FunctionalJavascript/TrainingEditInterfaceTest.php
View source
<?php
namespace Drupal\Tests\opigno_learning_path\FunctionalJavascript;
class TrainingEditInterfaceTest extends LearningPathWebDriverTestBase {
public function testTrainingInterfaceAccess() {
$content_manager = $this
->createUser();
$content_manager
->save();
$this
->drupalLogin($content_manager);
$this->accountSwitcher
->switchTo($content_manager);
$training = $this
->createGroup([
'uid' => $this->groupCreator,
]);
$this
->addGroupRoleForUser($training, $content_manager, [
'learning_path-content_manager',
]);
$training
->addMember($content_manager);
$module_1 = $this
->createOpignoModule([
'uid' => $this->groupCreator
->id(),
]);
$this
->addModuleToTraining($training, $module_1);
$module_2 = $this
->createOpignoModule([
'uid' => $content_manager
->id(),
]);
$this
->addModuleToTraining($training, $module_2);
$this
->drupalGet('/group/' . $training
->id() . '/inner-modules');
$this
->getSession()
->wait(2000);
$page = $this
->getSession()
->getPage();
$this
->assertEquals(FALSE, $page
->hasContent($module_1
->getName()), 'Local content manager can not see not own modules.');
$this
->assertEquals(TRUE, $page
->hasContent($module_2
->getName()), 'Local content manager can see own modules.');
$this
->assertEquals(TRUE, $page
->hasButton('Add activity'), 'Local content manager can add activities to own modules.');
}
}