Projet

Général

Profil

Paste
Télécharger (2,24 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / libraries / tests / LibrariesUnitTest.test @ 7c856df4

1 7c856df4 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Contains LibrariesUnitTest.
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
 * Tests basic Libraries API functions.
16
 */
17
class LibrariesUnitTest extends DrupalUnitTestCase {
18
19
  /**
20
   * Provides metadata about this test.
21
   *
22
   * @return array
23
   *   An array of test metadata with the following keys:
24
   *   - name: The name of the test.
25
   *   - description: The description of the test.
26
   *   - group: The group of the test.
27
   */
28
  public static function getInfo() {
29
    return array(
30
      'name' => 'Libraries API unit tests',
31
      'description' => 'Tests basic functions provided by Libraries API.',
32
      'group' => 'Libraries API',
33
    );
34
  }
35
36
  /**
37
   * {@inheritdoc}
38
   */
39
  protected function setUp() {
40
    drupal_load('module', 'libraries');
41
    parent::setUp();
42
  }
43
44
  /**
45
   * Tests libraries_get_path().
46
   */
47
  public function testLibrariesGetPath() {
48
    // Note that, even though libraries_get_path() doesn't find the 'example'
49
    // library, we are able to make it 'installed' by specifying the 'library
50
    // path' up-front. This is only used for testing purposed and is strongly
51
    // discouraged as it defeats the purpose of Libraries API in the first
52
    // place.
53
    $this->assertEqual(libraries_get_path('example'), FALSE, 'libraries_get_path() returns FALSE for a missing library.');
54
  }
55
56
  /**
57
   * Tests libraries_prepare_files().
58
   */
59
  public function testLibrariesPrepareFiles() {
60
    $expected = array(
61
      'files' => array(
62
        'js' => array('example.js' => array()),
63
        'css' => array('example.css' => array()),
64
        'php' => array('example.php' => array()),
65
      ),
66
    );
67
    $library = array(
68
      'files' => array(
69
        'js' => array('example.js'),
70
        'css' => array('example.css'),
71
        'php' => array('example.php'),
72
      ),
73
    );
74
    libraries_prepare_files($library, NULL, NULL);
75
    $this->assertEqual($expected, $library, 'libraries_prepare_files() works correctly.');
76
  }
77
78
}