Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / diff / src / Tests / DiffTestBase.php
1 <?php
2
3 namespace Drupal\diff\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Base class for Diff web tests.
9  */
10 abstract class DiffTestBase extends WebTestBase {
11
12   /**
13    * Modules to enable.
14    *
15    * @var array
16    */
17   public static $modules = [
18     'node',
19     'diff',
20     'block',
21   ];
22
23   /**
24    * Permissions for the admin user.
25    *
26    * @var array
27    */
28   protected $adminPermissions = [
29     'administer site configuration',
30     'administer nodes',
31     'administer content types',
32     'create article content',
33     'edit any article content',
34     'view article revisions',
35   ];
36
37   /**
38    * A user with content administrative permissions.
39    *
40    * @var \Drupal\user\UserInterface
41    */
42   protected $adminUser;
43
44   /**
45    * {@inheritdoc}
46    */
47   protected function setUp() {
48     parent::setUp();
49
50     // Create the Article content type.
51     $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
52
53     // Place the blocks that Diff module uses.
54     $this->drupalPlaceBlock('local_tasks_block');
55     $this->drupalPlaceBlock('local_actions_block');
56
57     // Make sure HTML Diff is disabled.
58     $config = \Drupal::configFactory()->getEditable('diff.settings');
59     $config->set('general_settings.layout_plugins.visual_inline.enabled', FALSE)->save();
60   }
61
62   /**
63    * Creates an user with admin permissions and log in.
64    *
65    * @param array $additional_permissions
66    *   Additional permissions that will be granted to admin user.
67    * @param bool $reset_permissions
68    *   Flag to determine if default admin permissions will be replaced by
69    *   $additional_permissions.
70    *
71    * @return \Drupal\user\Entity\User|false
72    *   Newly created and logged in user object.
73    */
74   protected function loginAsAdmin(array $additional_permissions = [], $reset_permissions = FALSE) {
75     $permissions = $this->adminPermissions;
76
77     if ($reset_permissions) {
78       $permissions = $additional_permissions;
79     }
80     elseif (!empty($additional_permissions)) {
81       $permissions = array_merge($permissions, $additional_permissions);
82     }
83
84     $this->adminUser = $this->drupalCreateUser($permissions);
85     $this->drupalLogin($this->adminUser);
86     return $this->adminUser;
87   }
88
89 }