You are here

public function ExecuteCodeTest::testHandleErrors in Devel PHP 8

Tests handle errors.

File

tests/src/Functional/ExecuteCodeTest.php, line 38

Class

ExecuteCodeTest
Tests execute code.

Namespace

Drupal\Tests\devel_php\Functional

Code

public function testHandleErrors() {
  $edit = [];
  $url = Url::fromRoute('devel_php.execute_php');
  $user = $this
    ->drupalCreateUser([
    'execute php code',
  ]);
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet($url);
  $edit['code'] = 'devel_help()';
  $this
    ->submitForm($edit, $this
    ->t('Execute'));
  $this
    ->assertSession()
    ->pageTextContains('syntax error, unexpected end of file');
  $edit['code'] = 'devel_help2();';
  $this
    ->submitForm($edit, $this
    ->t('Execute'));
  $this
    ->assertSession()
    ->pageTextContains('Call to undefined function devel_help2()');
  $edit['code'] = 'devel_help();';
  $this
    ->submitForm($edit, $this
    ->t('Execute'));
  $this
    ->assertSession()
    ->pageTextContains('Too few arguments to function devel_help(), 0 passed');
}