RestUITest.php in REST UI 8
File
tests/src/FunctionalJavascript/RestUITest.php
View source
<?php
namespace Drupal\Tests\restui\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\rest\RestResourceConfigInterface;
class RestUITest extends WebDriverTestBase {
protected $defaultTheme = 'classy';
public static $modules = [
'node',
'restui',
];
protected function setUp() {
parent::setUp();
$permissions = [
'administer site configuration',
'administer rest resources',
];
$account = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($account);
}
public function testConsumers() {
$this
->drupalGet('admin/config/services/rest');
$this
->assertSession()
->elementExists('css', 'div.rest-ui-list-section');
$this
->drupalGet('admin/config/services/rest/resource/entity%3Anode/edit');
$page = $this
->getSession()
->getPage();
$this
->assertSession()
->fieldExists('wrapper[settings][methods][GET]');
$this
->assertSession()
->fieldExists('wrapper[settings][formats][json]');
$this
->assertSession()
->fieldExists('wrapper[settings][authentication][cookie]');
$page
->findField('granularity')
->selectOption(RestResourceConfigInterface::METHOD_GRANULARITY);
$this
->assertSession()
->waitForField('wrapper[methods][GET]');
$page
->findField('wrapper[methods][GET][GET]')
->check();
$page
->findField('wrapper[methods][GET][settings][formats][json]')
->check();
$page
->findField('wrapper[methods][GET][settings][auth][cookie]')
->check();
$page
->pressButton('Save configuration');
$this
->assertSession()
->pageTextContains('The resource has been updated.');
$this
->drupalGet('admin/config/services/rest/resource/entity%3Anode/edit');
$page = $this
->getSession()
->getPage();
$page
->findField('granularity')
->selectOption(RestResourceConfigInterface::RESOURCE_GRANULARITY);
$this
->assertSession()
->waitForField('wrapper[settings][methods][GET]');
$page
->findField('wrapper[settings][methods][GET]')
->check();
$page
->findField('wrapper[settings][formats][json]')
->check();
$page
->findField('wrapper[settings][authentication][cookie]')
->check();
$page
->pressButton('Save configuration');
$this
->assertSession()
->pageTextContains('The resource has been updated.');
}
}