1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Contains LibrariesWebTestBase.
|
6
|
*
|
7
|
* Simpletest automatically discovers test files using PSR-4. We cannot,
|
8
|
* however, declare a namespace for this class, as that would require PHP 5.3.
|
9
|
* To prepare the PHP 5.3 requirement and the usage of PSR-4 in 7.x-3.x, we
|
10
|
* place the test files in the correct directory already, but for now register
|
11
|
* them explicitly in libraries.info
|
12
|
*/
|
13
|
|
14
|
/**
|
15
|
* Base class for Libraries API web tests.
|
16
|
*/
|
17
|
abstract class LibrariesWebTestBase extends DrupalWebTestCase {
|
18
|
|
19
|
/**
|
20
|
* {@inheritdoc}
|
21
|
*/
|
22
|
protected $profile = 'testing';
|
23
|
|
24
|
/**
|
25
|
* {@inheritdoc}
|
26
|
*/
|
27
|
protected function setUp() {
|
28
|
parent::setUp('libraries', 'libraries_test_module');
|
29
|
theme_enable(array('libraries_test_theme'));
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* Retrieves a path making sure a set of permissions is required to access it.
|
34
|
*
|
35
|
* After calling this method, a user with the given permissions is logged in
|
36
|
* and the retrieved page is loaded into the internal browser.
|
37
|
*
|
38
|
* @param array $permissions
|
39
|
* An array of permission names to assign to user. Note that the user always
|
40
|
* has the default permissions derived from the "authenticated users" role.
|
41
|
* @param string $path
|
42
|
* Drupal path or URL to load into the internal browser.
|
43
|
* @param array $options
|
44
|
* Options to be forwarded to url().
|
45
|
* @param array $headers
|
46
|
* An array containing additional HTTP request headers, each formatted as
|
47
|
* "name: value".
|
48
|
*
|
49
|
* @return string
|
50
|
* The retrieved HTML string, also available as $this->drupalGetContent().
|
51
|
*
|
52
|
* @see \DrupalWebTestCase::drupalGet()
|
53
|
* @see \DrupalWebTestCase::drupalCreateUser()
|
54
|
*/
|
55
|
protected function getWithPermissions(array $permissions, $path, array $options = array(), array $headers = array()) {
|
56
|
$this->drupalGet($path, $options, $headers);
|
57
|
$this->assertResponse(403);
|
58
|
|
59
|
$this->drupalLogin($this->drupalCreateUser($permissions));
|
60
|
$this->drupalGet($path, $options, $headers);
|
61
|
$this->assertResponse(200);
|
62
|
}
|
63
|
|
64
|
}
|