LocaleLibraryInfoAlterTest.php 914 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php
/**
 * @file
 * Definition of Drupal\locale\Tests\LocaleLibraryInfoAlterTest.
 */

namespace Drupal\locale\Tests;

use Drupal\simpletest\WebTestBase;

/**
 * Tests localization of the JavaScript libraries.
 *
 * Currently, only the jQuery datepicker is localized using Drupal translations.
15 16
 *
 * @group locale
17 18
 */
class LocaleLibraryInfoAlterTest extends WebTestBase {
19 20 21 22 23 24 25 26

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('locale');

27
  /**
28 29 30 31
   * Verifies that the datepicker can be localized.
   *
   * @see locale_library_info_alter()
   */
32
  public function testLibraryInfoAlter() {
33 34
    $attached['#attached']['library'][] = 'core/jquery.ui.datepicker';
    drupal_render($attached);
35
    drupal_process_attached($attached);
36
    $scripts = drupal_get_js();
37
    $this->assertTrue(strpos($scripts, 'locale.datepicker.js'), 'locale.datepicker.js added to scripts.');
38 39
  }
}