webex_client-1.0.5/tests/src/Functional/MakeDefaultControllerTest.php
tests/src/Functional/MakeDefaultControllerTest.php
<?php
declare(strict_types=1);
namespace Drupal\Tests\webex_client\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\webex_client\Entity\Webex;
/**
* Tests the Webex Make Default controller functionality.
*
* @group webex
*/
class MakeDefaultControllerTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['webex_client'];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'claro';
/**
* A user with permission to administer Webex.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser([
'administer webex client',
]);
$this->drupalLogin($this->adminUser);
}
/**
* Tests setting a Webex entity as default.
*/
public function testSetDefaultWebex(): void {
// Create two Webex entities.
$webex1 = Webex::create([
'id' => 'webex1',
'label' => 'First Webex',
]);
$webex1->save();
$webex2 = Webex::create([
'id' => 'webex2',
'label' => 'Second Webex',
]);
$webex2->save();
// Call the "make default" route for the first entity.
$this->drupalGet("/admin/config/system/webex/{$webex1->id()}/make-default");
// Reload both entities from storage.
$webex1 = Webex::load('webex1');
$webex2 = Webex::load('webex2');
// Assert states.
$this->assertTrue($webex1->isDefault(), 'First Webex is set as default.');
$this->assertFalse($webex2->isDefault(), 'Second Webex is not set as default.');
}
}
