Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / php / src / Tests / PhpAccessTest.php
1 <?php
2
3 namespace Drupal\php\Tests;
4
5 /**
6  * Tests to make sure access to the PHP filter is properly restricted.
7  *
8  * @group PHP
9  */
10 class PhpAccessTest extends PhpTestBase {
11
12   /**
13    * Makes sure that the user can't use the PHP filter when not given access.
14    */
15   public function testNoPrivileges() {
16     // Create node with PHP filter enabled.
17     $permissions = [
18       'access content',
19       'create page content',
20       'edit own page content',
21     ];
22     $web_user = $this->drupalCreateUser($permissions);
23     $this->drupalLogin($web_user);
24     $node = $this->createNodeWithCode();
25
26     // Make sure that the PHP code shows up as text.
27     $this->drupalGet('node/' . $node->id());
28     $this->assertText('print', 'PHP code was not evaluated.');
29
30     // Make sure that user doesn't have access to filter.
31     $this->drupalGet('node/' . $node->id() . '/edit');
32     $this->assertNoRaw('<option value="' . $this->phpCodeFormat->id() . '">', 'PHP code format not available.');
33   }
34
35 }