class RestExampleActionTest
Verify that the Views are accessible.
@group rest_example @group examples
Hierarchy
- class \Drupal\Tests\rest_example\Functional\RestExampleActionTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of RestExampleActionTest
Related topics
File
-
modules/
rest_example/ tests/ src/ Functional/ RestExampleActionTest.php, line 14
Namespace
Drupal\Tests\rest_example\FunctionalView source
class RestExampleActionTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'rest_example',
];
/**
* The installation profile to use with this test.
*
* @var string
*/
protected $profile = 'minimal';
/**
* {@inheritdoc}
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
protected function setUp() : void {
parent::setup();
global $base_url;
$account = $this->drupalCreateUser();
$this->drupalLogin($account);
$config_factory = \Drupal::configFactory();
$rest_config = $config_factory->getEditable('rest_example.settings');
$rest_config->set('server_url', $base_url)
->set('server_username', $account->get('name')->value)
->set('server_password', $account->passRaw)
->save();
}
/**
* Test that we access the client side View.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testClientNode() {
$this->drupalGet('examples/rest-client-actions');
$this->assertSession()
->responseContains('Nodes on the remote Drupal server');
}
/**
* Test that we can access the server side View.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testServerView() {
$this->drupalGet('rest/node');
$this->assertSession()
->responseContains('[]');
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| RestExampleActionTest::$defaultTheme | protected | property | |
| RestExampleActionTest::$modules | protected static | property | Modules to enable. |
| RestExampleActionTest::$profile | protected | property | The installation profile to use with this test. |
| RestExampleActionTest::setUp | protected | function | |
| RestExampleActionTest::testClientNode | public | function | Test that we access the client side View. |
| RestExampleActionTest::testServerView | public | function | Test that we can access the server side View. |