diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index 42ef70d..ada5734 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -56,8 +56,7 @@ a.block-demo-backlink:hover { } /* Wide screens */ -@media -screen and (min-width: 780px), +@media screen and (min-width: 780px), (orientation: landscape) and (min-device-height: 780px) { .block-list-primary { @@ -90,8 +89,8 @@ screen and (min-width: 780px), .block-list-secondary .form-color, .block-list-secondary textarea { -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; width: 100%; max-width: 100%; } @@ -103,8 +102,7 @@ screen and (min-width: 780px), * toolbar is on, we need to suppress layout for the original media width + the * toolbar width (240px). In this case, 240px + 780px. */ -@media -screen and (max-width: 1020px), +@media screen and (max-width: 1020px), (orientation: landscape) and (max-device-height: 1020px) { .toolbar-vertical .block-list-primary, diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index bfe5a39..d682efd 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -80,7 +80,7 @@ function custom_block_load($id) { * Implements hook_entity_type_alter(). */ function custom_block_entity_type_alter(array &$entity_types) { - /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + // @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] // Add a translation handler for fields if the language module is enabled. if (\Drupal::moduleHandler()->moduleExists('language')) { $translation = $entity_types['custom_block']->get('translation'); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php index e30c42d..6ee54b1 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php @@ -88,12 +88,12 @@ public function add(Request $request) { */ public function addForm(CustomBlockTypeInterface $custom_block_type, Request $request) { $block = $this->customBlockStorage->create(array( - 'type' => $custom_block_type->id() + 'type' => $custom_block_type->id(), )); if (($theme = $request->query->get('theme')) && in_array($theme, array_keys(list_themes()))) { - // We have navigated to this page from the block library and will keep track - // of the theme for redirecting the user to the configuration page for the - // newly created block in the given theme. + // We have navigated to this page from the block library and will keep + // track of the theme for redirecting the user to the configuration + // page for the newly created block in the given theme. $block->setTheme($theme); } return $this->entityFormBuilder()->getForm($block); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index a2f3008..3be9f6c 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -52,7 +52,7 @@ public function form(array $form, array &$form_state) { '#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $block_type->revision, - '#description' => t('Create a new revision by default for this block type.') + '#description' => t('Create a new revision by default for this block type.'), ); if ($this->moduleHandler->moduleExists('content_translation')) { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php index 514fc91..219ca69 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php @@ -65,11 +65,11 @@ class CustomBlockBlock extends BlockBase implements ContainerFactoryPluginInterf * The plugin ID for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\block\Plugin\Type\BlockManager + * @param \Drupal\block\Plugin\Type\BlockManager $block_manager * The Plugin Block Manager. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. - * @param \Drupal\Core\Extension\ModuleHandlerInterface + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The Module Handler. * @param \Drupal\Core\Session\AccountInterface $account * The account for which view access should be checked. @@ -126,7 +126,7 @@ public function blockForm($form, &$form_state) { '#options' => $this->entityManager->getViewModeOptions('custom_block'), '#title' => t('View mode'), '#description' => t('Output the block in this view mode.'), - '#default_value' => $this->configuration['view_mode'] + '#default_value' => $this->configuration['view_mode'], ); $form['title']['#description'] = t('The title of the block as shown to the user.'); return $form; @@ -155,9 +155,9 @@ public function build() { return array( '#markup' => t('Block with uuid %uuid does not exist. Add custom block.', array( '%uuid' => $uuid, - '!url' => url('block/add') + '!url' => url('block/add'), )), - '#access' => $this->account->hasPermission('administer blocks') + '#access' => $this->account->hasPermission('administer blocks'), ); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php index cee6ce8..de7026d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php @@ -29,7 +29,8 @@ public static function getInfo() { public function testCustomBlockRebuildContent() { $block = $this->createCustomBlock(); - // Set a property in the content array so we can test for its existence later on. + // Set a property in the content array so we can test for its existence + // later on. $block->content['test_content_property'] = array( '#value' => $this->randomString(), ); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php index 167014e..60b3ae2 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php @@ -67,7 +67,7 @@ public function testCustomBlockCreation() { // Check that the Basic block has been created. $this->assertRaw(format_string('!block %name has been created.', array( '!block' => 'Basic block', - '%name' => $edit['info[0][value]'] + '%name' => $edit['info[0][value]'], )), 'Basic block created.'); // Change the view mode. @@ -92,7 +92,7 @@ public function testCustomBlockCreation() { // Check that the Basic block has been created. $this->assertRaw(format_string('A block with description %name already exists.', array( - '%name' => $edit['info[0][value]'] + '%name' => $edit['info[0][value]'], ))); $this->assertResponse(200); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php index 5c7d46b..a9e0268 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php @@ -97,7 +97,7 @@ public function testBlockFields() { $edit = array( 'info[0][value]' => $this->randomName(8), $this->field->getName() . '[0][url]' => 'http://example.com', - $this->field->getName() . '[0][title]' => 'Example.com' + $this->field->getName() . '[0][title]' => 'Example.com', ); $this->drupalPostForm(NULL, $edit, t('Save')); $block = entity_load('custom_block', 1); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php index 82bcb44..8785955 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php @@ -23,6 +23,9 @@ class CustomBlockListTest extends WebTestBase { */ public static $modules = array('block', 'custom_block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Custom Block listing', diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php index ff0192e..27ea748 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php @@ -53,7 +53,7 @@ public function testImport() { 'info' => $info, 'body' => array('value' => $this->randomName(32)), 'type' => 'basic', - 'id' => $test_id + 'id' => $test_id, ); $block = entity_create('custom_block', $block_array); $block->enforceIsNew(TRUE); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php index cf731fc..2b378aa 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php @@ -32,7 +32,7 @@ * @var array */ protected $permissions = array( - 'administer blocks' + 'administer blocks', ); /** @@ -63,11 +63,11 @@ protected function setUp() { * Created custom block. */ protected function createCustomBlock($title = FALSE, $bundle = 'basic') { - $title = ($title ? : $this->randomName()); + $title = ($title ?: $this->randomName()); if ($custom_block = entity_create('custom_block', array( 'info' => $title, 'type' => $bundle, - 'langcode' => 'en' + 'langcode' => 'en', ))) { $custom_block->save(); } @@ -87,7 +87,7 @@ protected function createCustomBlockType($label) { $bundle = entity_create('custom_block_type', array( 'id' => $label, 'label' => $label, - 'revision' => FALSE + 'revision' => FALSE, )); $bundle->save(); return $bundle; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php index 761936e..6a4c97d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php @@ -21,20 +21,18 @@ class CustomBlockTranslationUITest extends ContentTranslationUITest { protected $name; /** - * Modules to enable. - * - * @var array + * {@inheritdoc} */ public static $modules = array( 'language', 'content_translation', 'block', 'field_ui', - 'custom_block' + 'custom_block', ); /** - * Declares test information. + * {@inheritdoc} */ public static function getInfo() { return array( @@ -45,7 +43,7 @@ public static function getInfo() { } /** - * Overrides \Drupal\simpletest\WebTestBase::setUp(). + * {@inheritdoc} */ public function setUp() { $this->entityTypeId = 'custom_block'; @@ -56,14 +54,14 @@ public function setUp() { } /** - * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getTranslatorPermission(). + * {@inheritdoc} */ public function getTranslatorPermissions() { return array_merge(parent::getTranslatorPermissions(), array( 'translate any entity', 'access administration pages', 'administer blocks', - 'administer custom_block fields' + 'administer custom_block fields', )); } @@ -81,26 +79,26 @@ public function getTranslatorPermissions() { * Created custom block. */ protected function createCustomBlock($title = FALSE, $bundle = FALSE) { - $title = ($title ? : $this->randomName()); - $bundle = ($bundle ? : $this->bundle); + $title = ($title ?: $this->randomName()); + $bundle = ($bundle ?: $this->bundle); $custom_block = entity_create('custom_block', array( 'info' => $title, 'type' => $bundle, - 'langcode' => 'en' + 'langcode' => 'en', )); $custom_block->save(); return $custom_block; } /** - * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). + * {@inheritdoc} */ protected function getNewEntityValues($langcode) { return array('info' => $this->name) + parent::getNewEntityValues($langcode); } /** - * Returns an edit array containing the values to be posted. + * {@inheritdoc} */ protected function getEditValues($values, $langcode, $new = FALSE) { $edit = parent::getEditValues($values, $langcode, $new); @@ -122,7 +120,7 @@ public function testDisabledBundle() { $bundle = entity_create('custom_block_type', array( 'id' => $disabled_bundle, 'label' => $disabled_bundle, - 'revision' => FALSE + 'revision' => FALSE, )); $bundle->save(); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php index 739f234..a1ba0fa 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php @@ -26,7 +26,7 @@ class CustomBlockTypeTest extends CustomBlockTestBase { */ protected $permissions = array( 'administer blocks', - 'administer custom_block fields' + 'administer custom_block fields', ); /** @@ -163,12 +163,13 @@ public function testsCustomBlockAddTypes() { // For each enabled theme, go to its block page and test the redirects. $themes = array('bartik', 'stark', 'seven'); foreach ($themes as $theme) { - // Test that adding a block from the 'place blocks' form sends you to the - // block configure form. + // Test that adding a block from the 'place blocks' form sends you to + // the block configure form. $path = $theme == $default_theme ? 'admin/structure/block' : "admin/structure/block/list/$theme"; $this->drupalGet($path); $this->clickLink(t('Add custom block')); - // The seven theme has markup inside the link, we cannot use clickLink(). + // The seven theme has markup inside the link, we cannot use + // clickLink(). if ($default_theme == 'seven') { $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array(); $this->assertLinkByHref(url('block/add/foo', $options)); diff --git a/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php b/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php index d04ad15..1bf586c 100644 --- a/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php +++ b/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php @@ -17,6 +17,9 @@ */ class CustomBlockLocalTasksTest extends LocalTaskIntegrationTest { + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Custom Block local tasks test', @@ -25,6 +28,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ public function setUp() { $this->directoryList = array( 'block' => 'core/modules/block', @@ -39,7 +45,6 @@ public function setUp() { * @dataProvider getCustomBlockListingRoutes */ public function testCustomBlockListLocalTasks($route) { - // $this->assertLocalTasks($route, array( 0 => array( 'block.admin_display', @@ -48,7 +53,7 @@ public function testCustomBlockListLocalTasks($route) { 1 => array( 'custom_block.list_sub', 'custom_block.type_list', - ) + ), )); } diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module index 8c53053..8038925 100644 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module +++ b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module @@ -25,12 +25,12 @@ function custom_block_test_custom_block_view(CustomBlock $custom_block, $view_mo */ function custom_block_test_custom_block_presave(CustomBlock $custom_block) { if ($custom_block->label() == 'testing_custom_block_presave') { - $custom_block->setInfo($custom_block->label() .'_presave'); + $custom_block->setInfo($custom_block->label() . '_presave'); } // Determine changes. if (!empty($custom_block->original) && $custom_block->original->label() == 'test_changes') { if ($custom_block->original->label() != $custom_block->label()) { - $custom_block->setInfo($custom_block->label() .'_presave'); + $custom_block->setInfo($custom_block->label() . '_presave'); // Drupal 1.0 release. $custom_block->changed = 979534800; } @@ -44,7 +44,7 @@ function custom_block_test_custom_block_update(CustomBlock $custom_block) { // Determine changes on update. if (!empty($custom_block->original) && $custom_block->original->label() == 'test_changes') { if ($custom_block->original->label() != $custom_block->label()) { - $custom_block->setInfo($custom_block->label() .'_update'); + $custom_block->setInfo($custom_block->label() . '_update'); } } } diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index 44a4a74..4dda8c8 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -53,6 +53,7 @@ else { $blocks.show(); $details.show(); + // Return
elements that had been closed before filtering // to a closed state. $details.filter('[data-drupal-block-state="forced-open"]').removeAttr('open data-drupal-block-state'); diff --git a/core/modules/block/js/block.js b/core/modules/block/js/block.js index 302c315..2b2afdc 100644 --- a/core/modules/block/js/block.js +++ b/core/modules/block/js/block.js @@ -53,8 +53,11 @@ return; } + // Select the 'blocks' table. var table = $('#blocks'); - var tableDrag = Drupal.tableDrag.blocks; // Get the blocks tableDrag object. + + // Get the blocks tableDrag object. + var tableDrag = Drupal.tableDrag.blocks; // Add a handler for when a row is swapped, update empty regions. tableDrag.row.prototype.onSwap = function (swappedRow) { diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index af0c1a4..7a82b2a 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -130,7 +130,8 @@ public function buildConfigurationForm(array $form, array &$form_state) { ); // Identical options to the ones for page caching. // @see \Drupal\system\Form\PerformanceForm::buildForm() - $period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400); + $period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, + 10800, 21600, 32400, 43200, 86400); $period = array_map('format_interval', array_combine($period, $period)); $period[0] = '<' . t('no caching') . '>'; $period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever'); @@ -294,7 +295,7 @@ public function getCacheBin() { * {@inheritdoc} */ public function getCacheMaxAge() { - return (int)$this->configuration['cache']['max_age']; + return (int) $this->configuration['cache']['max_age']; } /** diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 4b4c859..55f59ac 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -148,7 +148,11 @@ public function form(array $form, array &$form_state) { BLOCK_VISIBILITY_NOTLISTED => $this->t('All pages except those listed'), BLOCK_VISIBILITY_LISTED => $this->t('Only the listed pages'), ); - $description = $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array('%user' => 'user', '%user-wildcard' => 'user/*', '%front' => '')); + $description = $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array( + '%user' => 'user', + '%user-wildcard' => 'user/*', + '%front' => '', + )); $form['visibility']['path']['visibility'] = array( '#type' => 'radios', @@ -293,7 +297,7 @@ public function validate(array $form, array &$form_state) { // The Block Entity form puts all block plugin form elements in the // settings form element, so just pass that to the block for validation. $settings = array( - 'values' => &$form_state['values']['settings'] + 'values' => &$form_state['values']['settings'], ); // Call the plugin validate handler. $this->entity->getPlugin()->validateConfigurationForm($form, $settings); @@ -330,7 +334,7 @@ public function submit(array $form, array &$form_state) { 'theme' => $form_state['values']['theme'], ), 'options' => array( - 'query' => array('block-placement' => drupal_html_class($this->entity->id())) + 'query' => array('block-placement' => drupal_html_class($this->entity->id())), ), ); } diff --git a/core/modules/block/lib/Drupal/block/BlockPluginBag.php b/core/modules/block/lib/Drupal/block/BlockPluginBag.php index 5693281..b6d85ff 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginBag.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginBag.php @@ -46,6 +46,7 @@ public function __construct(PluginManagerInterface $manager, $instance_id, array * {@inheritdoc} * * @return \Drupal\block\BlockPluginInterface + * Retrieves a plugin instance, initializing it if necessary. */ public function &get($instance_id) { return parent::get($instance_id); diff --git a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php index 4f6bdc2..568ffed 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php @@ -59,7 +59,8 @@ public function build(); * * @todo This doesn't belong here. Move this into a new base class in * http://drupal.org/node/1764380. - * @todo This does not set a value in \Drupal::config(), so the name is confusing. + * @todo This does not set a value in \Drupal::config(), so the name is + * confusing. * * @see \Drupal\Component\Plugin\PluginBase::$configuration */ @@ -76,8 +77,8 @@ public function setConfigurationValue($key, $value); * @param array $form_state * An array containing the current state of the configuration form. * - * @return array $form - * The renderable form array representing the entire configuration form. + * @return array + * The renderable array $form representing the entire configuration form. */ public function blockForm($form, &$form_state); diff --git a/core/modules/block/lib/Drupal/block/BlockViewBuilder.php b/core/modules/block/lib/Drupal/block/BlockViewBuilder.php index cb44851..28f4583 100644 --- a/core/modules/block/lib/Drupal/block/BlockViewBuilder.php +++ b/core/modules/block/lib/Drupal/block/BlockViewBuilder.php @@ -78,7 +78,6 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la ); $build[$entity_id]['#cache']['tags'] = NestedArray::mergeDeep($default_cache_tags, $plugin->getCacheTags()); - if ($plugin->isCacheable()) { $build[$entity_id]['#pre_render'][] = array($this, 'buildBlock'); // Generic cache keys, with the block plugin's custom keys appended @@ -114,7 +113,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la } /** - * #pre_render callback for building a block. + * The #pre_render callback for building a block. * * Renders the content using the provided block plugin, and then: * - if there is no content, aborts rendering, and makes sure the block won't @@ -154,7 +153,7 @@ public function buildBlock($build) { ); } return $build; - } + } /** * {@inheritdoc} diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockController.php b/core/modules/block/lib/Drupal/block/Controller/BlockController.php index 7b713e4..9c4f89a 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockController.php @@ -38,7 +38,7 @@ public function demo($theme) { // pages, it needs to know this is an actual administrative page. 'data' => array('path' => array('currentPathIsAdmin' => TRUE)), 'type' => 'setting', - ) + ), ), 'library' => array( 'block/drupal.block.admin', diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php index aa9141c..03664fa 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -116,7 +116,7 @@ public function getPluginBag() { } /** - * Overrides \Drupal\Core\Entity\Entity::label(); + * {@inheritdoc} */ public function label() { $settings = $this->get('settings'); diff --git a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php index 9ee2ca9..f5fff81 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php @@ -41,6 +41,9 @@ class Block extends DisplayPluginBase { */ protected $usesAttachments = TRUE; + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -152,6 +155,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#default_value' => $this->getOption('block_description'), ); break; + case 'block_category': $form['#title'] .= t('Block category'); $form['block_category'] = array( @@ -161,6 +165,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#default_value' => $this->getOption('block_category'), ); break; + case 'block_hide_empty': $form['#title'] .= t('Block empty settings'); @@ -171,6 +176,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#default_value' => $this->getOption('block_hide_empty'), ); break; + case 'exposed_form_options': $this->view->initHandlers(); if (!$this->usesExposed() && parent::usesExposed()) { @@ -180,6 +186,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); } break; + case 'allow': $form['#title'] .= t('Allow settings in the block configuration'); @@ -194,11 +201,13 @@ public function buildOptionsForm(&$form, &$form_state) { '#options' => $options, ); break; + } } /** * Perform any necessary changes to the form values prior to storage. + * * There is no need for this function to actually store the data. */ public function submitOptionsForm(&$form, &$form_state) { @@ -225,9 +234,8 @@ public function submitOptionsForm(&$form, &$form_state) { * @param array $form_state * An array containing the current state of the configuration form. * - * @return array $form - * The renderable form array representing the entire configuration form. - * + * @return array + * The renderable array $form representing the entire configuration form. * @see \Drupal\views\Plugin\Block\ViewsBlock::blockForm() */ public function blockForm(ViewsBlock $block, array &$form, array &$form_state) { @@ -310,11 +318,11 @@ public function preBlockBuild(ViewsBlock $block) { * Block views use exposed widgets only if AJAX is set. */ public function usesExposed() { - if ($this->ajaxEnabled()) { - return parent::usesExposed(); - } - return FALSE; + if ($this->ajaxEnabled()) { + return parent::usesExposed(); } + return FALSE; + } /** * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::remove(). diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php index d553440..a3d4b9b 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php @@ -21,6 +21,9 @@ class BlockAdminThemeTest extends WebTestBase { */ public static $modules = array('block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Administration theme', @@ -32,7 +35,7 @@ public static function getInfo() { /** * Check for the accessibility of the admin theme on the block admin page. */ - function testAdminTheme() { + public function testAdminTheme() { // Create administrative user. $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); $this->drupalLogin($admin_user); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php index ce78720..14e3a0e 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php @@ -22,9 +22,9 @@ class BlockCacheTest extends WebTestBase { */ public static $modules = array('block', 'block_test'); - protected $admin_user; - protected $normal_user; - protected $normal_user_alt; + protected $adminUser; + protected $normalUser; + protected $normalUserAlt; /** * The block used by this test. @@ -33,6 +33,9 @@ class BlockCacheTest extends WebTestBase { */ protected $block; + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block caching', @@ -41,29 +44,32 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Create an admin user, log in and enable test blocks. - $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'access administration pages')); + $this->drupalLogin($this->adminUser); // Create additional users to test caching modes. - $this->normal_user = $this->drupalCreateUser(); - $this->normal_user_alt = $this->drupalCreateUser(); + $this->normalUser = $this->drupalCreateUser(); + $this->normalUserAlt = $this->drupalCreateUser(); // Sync the roles, since drupalCreateUser() creates separate roles for // the same permission sets. - $this->normal_user_alt->roles = $this->normal_user->getRoles(); - $this->normal_user_alt->save(); + $this->normalUserAlt->roles = $this->normalUser->getRoles(); + $this->normalUserAlt->save(); // Enable our test block. - $this->block = $this->drupalPlaceBlock('test_cache'); + $this->block = $this->drupalPlaceBlock('test_cache'); } /** * Test "cache_context.user.roles" cache context. */ - function testCachePerRole() { + public function testCachePerRole() { $this->setBlockCacheConfig(array( 'max_age' => 600, 'contexts' => array('cache_context.user.roles'), @@ -72,7 +78,7 @@ function testCachePerRole() { // Enable our test block. Set some content for it to display. $current_content = $this->randomName(); \Drupal::state()->set('block_test.content', $current_content); - $this->drupalLogin($this->normal_user); + $this->drupalLogin($this->normalUser); $this->drupalGet(''); $this->assertText($current_content, 'Block content displays.'); @@ -97,15 +103,15 @@ function testCachePerRole() { $this->drupalGet(''); $this->assertNoText($old_content, 'Anonymous user does not see content cached per-role for normal user.'); - $this->drupalLogin($this->normal_user_alt); + $this->drupalLogin($this->normalUserAlt); $this->drupalGet(''); $this->assertText($old_content, 'User with the same roles sees per-role cached content.'); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet(''); $this->assertNoText($old_content, 'Admin user does not see content cached per-role for normal user.'); - $this->drupalLogin($this->normal_user); + $this->drupalLogin($this->normalUser); $this->drupalGet(''); $this->assertText($old_content, 'Block is served from the per-role cache.'); } @@ -113,7 +119,7 @@ function testCachePerRole() { /** * Test a cacheable block without any cache context. */ - function testCacheGlobal() { + public function testCacheGlobal() { $this->setBlockCacheConfig(array( 'max_age' => 600, )); @@ -136,7 +142,7 @@ function testCacheGlobal() { /** * Test non-cacheable block. */ - function testNoCache() { + public function testNoCache() { $this->setBlockCacheConfig(array( 'max_age' => 0, )); @@ -158,7 +164,7 @@ function testNoCache() { /** * Test "cache_context.user" cache context. */ - function testCachePerUser() { + public function testCachePerUser() { $this->setBlockCacheConfig(array( 'max_age' => 600, 'contexts' => array('cache_context.user'), @@ -166,7 +172,7 @@ function testCachePerUser() { $current_content = $this->randomName(); \Drupal::state()->set('block_test.content', $current_content); - $this->drupalLogin($this->normal_user); + $this->drupalLogin($this->normalUser); $this->drupalGet(''); $this->assertText($current_content, 'Block content displays.'); @@ -178,11 +184,11 @@ function testCachePerUser() { $this->drupalGet(''); $this->assertText($old_content, 'Block is served from per-user cache.'); - $this->drupalLogin($this->normal_user_alt); + $this->drupalLogin($this->normalUserAlt); $this->drupalGet(''); $this->assertText($current_content, 'Per-user block cache is not served for other users.'); - $this->drupalLogin($this->normal_user); + $this->drupalLogin($this->normalUser); $this->drupalGet(''); $this->assertText($old_content, 'Per-user block cache is persistent.'); } @@ -190,7 +196,7 @@ function testCachePerUser() { /** * Test "cache_context.url" cache context. */ - function testCachePerPage() { + public function testCachePerPage() { $this->setBlockCacheConfig(array( 'max_age' => 600, 'contexts' => array('cache_context.url'), diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php index 3fa85d6..d05c63a 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php @@ -26,6 +26,9 @@ class BlockHiddenRegionTest extends WebTestBase { */ public static $modules = array('block', 'block_test', 'search'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Blocks not in hidden region', @@ -34,7 +37,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Create administrative user. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php index 52120f1..0bc9a82 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHookOperationTest.php @@ -22,6 +22,9 @@ class BlockHookOperationTest extends WebTestBase { */ public static $modules = array('block', 'entity_test'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block operations hook', @@ -30,7 +33,10 @@ public static function getInfo() { ); } - public function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); $permissions = array( @@ -42,7 +48,7 @@ public function setUp() { $this->drupalLogin($admin_user); } - /* + /** * Tests the block list to see if the test_operation link is added. */ public function testBlockOperationAlter() { diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlTest.php index 63579b9..f433e7e 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlTest.php @@ -21,6 +21,9 @@ class BlockHtmlTest extends WebTestBase { */ public static $modules = array('block', 'block_test'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block HTML', @@ -29,7 +32,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); $this->drupalLogin($this->root_user); @@ -46,7 +52,7 @@ function setUp() { /** * Tests for valid HTML for a block. */ - function testHtml() { + public function testHtml() { $this->drupalGet(''); // Ensure that a block's ID is converted to an HTML valid ID, and that diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php index 6214e0c..5ea01cb 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php @@ -16,6 +16,9 @@ class BlockInterfaceTest extends DrupalUnitTestBase { public static $modules = array('system', 'block', 'block_test', 'user'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block Plugins Tests', @@ -63,7 +66,22 @@ public function testBlockInterface() { $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block configuration was updated correctly.'); $definition = $display_block->getPluginDefinition(); - $period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400); + $period = array( + 0, + 60, + 180, + 300, + 600, + 900, + 1800, + 2700, + 3600, + 10800, + 21600, + 32400, + 43200, + 86400, + ); $period = array_map('format_interval', array_combine($period, $period)); $period[0] = '<' . t('no caching') . '>'; $period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever'); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockInvalidRegionTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockInvalidRegionTest.php index b44c4e2..5bde02a 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockInvalidRegionTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockInvalidRegionTest.php @@ -21,6 +21,9 @@ class BlockInvalidRegionTest extends WebTestBase { */ public static $modules = array('block', 'block_test'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Blocks in invalid regions', @@ -29,7 +32,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Create an admin user. $admin_user = $this->drupalCreateUser(array( @@ -43,7 +49,7 @@ function setUp() { /** * Tests that blocks assigned to invalid regions work correctly. */ - function testBlockInInvalidRegion() { + public function testBlockInInvalidRegion() { // Enable a test block and place it in an invalid region. $block = $this->drupalPlaceBlock('test_html'); $block->set('region', 'invalid_region'); @@ -51,7 +57,8 @@ function testBlockInInvalidRegion() { $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block->id(), '%region' => 'invalid_region')); - // Clearing the cache should disable the test block placed in the invalid region. + // Clearing the cache should disable the test block placed in the + // invalid region. $this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches'); $this->assertRaw($warning_message, 'Enabled block was in the invalid region and has been disabled.'); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php index 5fec407..d634064 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php @@ -30,6 +30,9 @@ class BlockLanguageCacheTest extends WebTestBase { */ protected $langcodes = array(); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Multilingual blocks', @@ -38,7 +41,10 @@ public static function getInfo() { ); } - public function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Create test languages. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php index 246e92c..be4ee54 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php @@ -26,6 +26,9 @@ class BlockLanguageTest extends WebTestBase { */ public static $modules = array('language', 'block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Language block visibility', @@ -34,11 +37,18 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Create a new user, allow him to manage the blocks and the languages. - $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'administer languages', 'administer site configuration')); + $this->adminUser = $this->drupalCreateUser(array( + 'administer blocks', + 'administer languages', + 'administer site configuration', + )); $this->drupalLogin($this->adminUser); // Add predefined language. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php index e343019..7fecb5d 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php @@ -21,6 +21,9 @@ class BlockPreprocessUnitTest extends WebTestBase { */ public static $modules = array('block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block preprocess', @@ -32,7 +35,7 @@ public static function getInfo() { /** * Tests block classes with template_preprocess_block(). */ - function testBlockClasses() { + public function testBlockClasses() { // Define a block with a derivative to be preprocessed, which includes both // an underscore (not transformed) and a hyphen (transformed to underscore), // and generates possibilities for each level of derivative. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php index b6aa269..a685297 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php @@ -21,6 +21,9 @@ class BlockRenderOrderTest extends WebTestBase { */ public static $modules = array('node', 'block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block Render Order', @@ -29,7 +32,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Create a test user. $end_user = $this->drupalCreateUser(array( @@ -41,7 +47,7 @@ function setUp() { /** * Tests the render order of the blocks. */ - function testBlockRenderOrder() { + public function testBlockRenderOrder() { // Enable test blocks and place them in the same region. $region = 'header'; $test_blocks = array( diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index a84bdc4..6475902 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -33,14 +33,20 @@ class BlockStorageUnitTest extends DrupalUnitTestBase { */ protected $controller; + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block storage', 'description' => 'Tests the storage of blocks.', - 'group' => 'Block' + 'group' => 'Block', ); } + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php index 604b1a7..c471922 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php @@ -21,6 +21,9 @@ class BlockTemplateSuggestionsUnitTest extends WebTestBase { */ public static $modules = array('block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block template suggestions', @@ -32,7 +35,7 @@ public static function getInfo() { /** * Tests template suggestions from block_theme_suggestions_block(). */ - function testBlockThemeHookSuggestions() { + public function testBlockThemeHookSuggestions() { // Define a block with a derivative to be preprocessed, which includes both // an underscore (not transformed) and a hyphen (transformed to underscore), // and generates possibilities for each level of derivative. @@ -52,7 +55,10 @@ function testBlockThemeHookSuggestions() { $variables['elements']['#derivative_plugin_id'] = $plugin->getDerivativeId(); $variables['elements']['content'] = array(); $suggestions = block_theme_suggestions_block($variables); - $this->assertEqual($suggestions, array('block__system', 'block__system_menu_block', 'block__system_menu_block__admin', 'block__machinename')); + $this->assertEqual($suggestions, array( + 'block__system', + 'block__system_menu_block', + 'block__system_menu_block__admin', 'block__machinename')); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index 37074cc..2e90d49 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -15,6 +15,9 @@ */ class BlockTest extends BlockTestBase { + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block functionality', @@ -26,7 +29,7 @@ public static function getInfo() { /** * Tests block visibility. */ - function testBlockVisibility() { + public function testBlockVisibility() { $block_name = 'system_powered_by_block'; // Create a random title for the block. $title = $this->randomName(8); @@ -64,10 +67,9 @@ function testBlockVisibility() { } /** - * Test block visibility when using "pages" restriction but leaving - * "pages" textarea empty + * Test block visibility with "pages" restriction and "pages" textarea empty. */ - function testBlockVisibilityListedEmpty() { + public function testBlockVisibilityListedEmpty() { $block_name = 'system_powered_by_block'; // Create a random title for the block. $title = $this->randomName(8); @@ -99,7 +101,7 @@ function testBlockVisibilityListedEmpty() { /** * Test configuring and moving a module-define block to specific regions. */ - function testBlock() { + public function testBlock() { // Select the 'Powered by Drupal' block to be configured and moved. $block = array(); $block['id'] = 'system_powered_by_block'; @@ -107,8 +109,14 @@ function testBlock() { $block['theme'] = \Drupal::config('system.theme')->get('default'); $block['region'] = 'header'; - // Set block title to confirm that interface works and override any custom titles. - $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'id' => $block['id'], 'region' => $block['region']), t('Save block')); + // Set block title to confirm that interface works and override any custom + // titles. + $this->drupalPostForm( + 'admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], + array( + 'settings[label]' => $block['settings[label]'], + 'id' => $block['id'], 'region' => $block['region']), t('Save block') + ); $this->assertText(t('The block configuration has been saved.'), 'Block title set.'); // Check to see if the block was created by checking its configuration. $instance = entity_load('block', $block['id']); @@ -130,10 +138,12 @@ function testBlock() { // Confirm that the block instance title and markup are not displayed. $this->drupalGet('node'); - $this->assertNoText(t($block['settings[label]'])); + $this->assertNoText($block['settings[label]']); // Check for
if the machine name // is my_block_instance_name. - $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . str_replace('_', '-', strtolower($block['id'])))); + $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array( + ':id' => 'block-' . str_replace('_', '-', strtolower($block['id'])), + )); $this->assertNoFieldByXPath($xpath, FALSE, 'Block found in no regions.'); // Test deleting the block from the edit form. @@ -184,7 +194,7 @@ public function testBlockThemeSelector() { /** * Test block title display settings. */ - function testHideBlockTitle() { + public function testHideBlockTitle() { $block_name = 'system_powered_by_block'; // Create a random title for the block. $title = $this->randomName(8); @@ -227,7 +237,7 @@ function testHideBlockTitle() { * The machine name of the theme region to move the block to, for example * 'header' or 'sidebar_first'. */ - function moveBlockToRegion(array $block, $region) { + public function moveBlockToRegion(array $block, $region) { // Set the created block to a specific region. $block += array('theme' => \Drupal::config('system.theme')->get('default')); $edit = array(); @@ -235,11 +245,11 @@ function moveBlockToRegion(array $block, $region) { $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks')); // Confirm that the block was moved to the proper region. - $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region))); + $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array('%region_name' => $region))); // Confirm that the block is being displayed. $this->drupalGet(''); - $this->assertText(t($block['settings[label]']), 'Block successfully being displayed on the page.'); + $this->assertText(t('@label', array('@label' => $block['settings[label]'])), 'Block successfully being displayed on the page.'); // Confirm that the custom block was found at the proper region. $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array( diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php index 88073c3..27ef318 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php @@ -35,7 +35,10 @@ */ protected $adminUser; - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Use the test page as the front page. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php index f185f58..7abfcda 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php @@ -21,6 +21,9 @@ class BlockTitleXSSTest extends WebTestBase { */ public static $modules = array('block', 'block_test'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block XSS Title', @@ -29,6 +32,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); @@ -38,7 +44,7 @@ protected function setUp() { /** * Test XSS in title. */ - function testXSSInTitle() { + public function testXSSInTitle() { \Drupal::state()->set('block_test.content', $this->randomName()); $this->drupalGet(''); $this->assertNoRaw('', 'The block title was properly sanitized when rendered.'); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php index 356d480..7032146 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php @@ -42,6 +42,9 @@ class BlockUiTest extends WebTestBase { */ protected $adminUser; + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block UI', @@ -50,7 +53,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); // Create and log in an administrative user. $this->adminUser = $this->drupalCreateUser(array( @@ -96,7 +102,7 @@ public function testBlockDemoUiPage() { /** * Test block admin page exists and functions correctly. */ - function testBlockAdminUiPage() { + public function testBlockAdminUiPage() { // Visit the blocks admin ui. $this->drupalGet('admin/structure/block'); // Look for the blocks table. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockViewBuilderTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockViewBuilderTest.php index d4066b0..85f809d 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockViewBuilderTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockViewBuilderTest.php @@ -204,14 +204,14 @@ public function testBlockViewBuilderAlter() { // Basic: non-empty block. $build = $this->getBlockRenderArray(); - $this->assertTrue(isset($build['#suffix']) && $build['#suffix'] === '
Goodbye!', 'A block with content is altered.'); - $this->assertIdentical(drupal_render($build), 'Llamas > unicorns!
Goodbye!'); + $this->assertTrue(isset($build['#suffix']) && $build['#suffix'] === '
Goodbye!', 'A block with content is altered.'); + $this->assertIdentical(drupal_render($build), 'Llamas > unicorns!
Goodbye!'); // Basic: empty block. \Drupal::state()->set('block_test.content', NULL); $build = $this->getBlockRenderArray(); - $this->assertTrue(isset($build['#suffix']) && $build['#suffix'] === '
Goodbye!', 'A block without content is altered.'); - $this->assertIdentical(drupal_render($build), '
Goodbye!'); + $this->assertTrue(isset($build['#suffix']) && $build['#suffix'] === '
Goodbye!', 'A block without content is altered.'); + $this->assertIdentical(drupal_render($build), '
Goodbye!'); // Disable the block view alter hook that adds a suffix, for basic testing. \Drupal::state()->set('block_test_view_alter_suffix', FALSE); @@ -220,8 +220,20 @@ public function testBlockViewBuilderAlter() { $request_method = \Drupal::request()->server->get('REQUEST_METHOD'); $this->container->get('request')->setMethod('GET'); - $default_keys = array('entity_view', 'block', 'test_block', 'en', 'cache_context.theme'); - $default_tags = array('content' => TRUE, 'block_view' => TRUE, 'block' => array('test_block'), 'theme' => 'stark', 'block_plugin' => array('test_cache')); + $default_keys = array( + 'entity_view', + 'block', + 'test_block', + 'en', + 'cache_context.theme', + ); + $default_tags = array( + 'content' => TRUE, + 'block_view' => TRUE, + 'block' => array('test_block'), + 'theme' => 'stark', + 'block_plugin' => array('test_cache'), + ); // Advanced: cached block, but an alter hook adds an additional cache key. $this->setBlockCacheConfig(array( @@ -236,8 +248,16 @@ public function testBlockViewBuilderAlter() { $this->assertIdentical(drupal_render($build), ''); $cache_entry = $this->container->get('cache.render')->get($cid); $this->assertTrue($cache_entry, 'The block render element has been cached with the expected cache ID.'); - $expected_flattened_tags = array('content:1', 'block_view:1', 'block:test_block', 'theme:stark', 'block_plugin:test_cache'); - $this->assertIdentical($cache_entry->tags, array_combine($expected_flattened_tags, $expected_flattened_tags)); //, 'The block render element has been cached with the expected cache tags.'); + $expected_flattened_tags = array( + 'content:1', + 'block_view:1', + 'block:test_block', + 'theme:stark', + 'block_plugin:test_cache', + ); + + // The block render element has been cached with the expected cache tags. + $this->assertIdentical($cache_entry->tags, array_combine($expected_flattened_tags, $expected_flattened_tags)); $this->container->get('cache.render')->delete($cid); // Advanced: cached block, but an alter hook adds an additional cache tag. @@ -250,8 +270,18 @@ public function testBlockViewBuilderAlter() { $this->assertIdentical(drupal_render($build), ''); $cache_entry = $this->container->get('cache.render')->get($cid); $this->assertTrue($cache_entry, 'The block render element has been cached with the expected cache ID.'); - $expected_flattened_tags = array('content:1', 'block_view:1', 'block:test_block', 'theme:stark', 'block_plugin:test_cache', $alter_add_tag . ':1'); - $this->assertIdentical($cache_entry->tags, array_combine($expected_flattened_tags, $expected_flattened_tags)); //, 'The block render element has been cached with the expected cache tags.'); + $expected_flattened_tags = array( + 'content:1', + 'block_view:1', + 'block:test_block', + 'theme:stark', + 'block_plugin:test_cache', + $alter_add_tag . ':1', + ); + + // The block render element has been cached with the expected cache tags. + $this->assertIdentical($cache_entry->tags, array_combine($expected_flattened_tags, $expected_flattened_tags)); + $this->container->get('cache.render')->delete($cid); // Advanced: cached block, but an alter hook adds a #pre_render callback to @@ -259,8 +289,8 @@ public function testBlockViewBuilderAlter() { \Drupal::state()->set('block_test_view_alter_append_pre_render_prefix', TRUE); $build = $this->getBlockRenderArray(); $this->assertFalse(isset($build['#prefix']), 'The appended #pre_render callback has not yet run before calling drupal_render().'); - $this->assertIdentical(drupal_render($build), 'Hiya!
'); - $this->assertTrue(isset($build['#prefix']) && $build['#prefix'] === 'Hiya!
', 'A cached block without content is altered.'); + $this->assertIdentical(drupal_render($build), 'Hiya!
'); + $this->assertTrue(isset($build['#prefix']) && $build['#prefix'] === 'Hiya!
', 'A cached block without content is altered.'); // Restore the previous request method. $this->container->get('request')->setMethod($request_method); diff --git a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php index c544960..d1a201c 100644 --- a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php @@ -21,6 +21,9 @@ class NewDefaultThemeBlocksTest extends WebTestBase { */ public static $modules = array('block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'New default theme blocks', @@ -32,7 +35,7 @@ public static function getInfo() { /** * Check the enabled Bartik blocks are correctly copied over. */ - function testNewDefaultThemeBlocks() { + public function testNewDefaultThemeBlocks() { $default_theme = \Drupal::config('system.theme')->get('default'); // Add two instances of the user login block. diff --git a/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php b/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php index 72f3d1d..a6e7ec6 100644 --- a/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php @@ -18,6 +18,9 @@ class NonDefaultBlockAdminTest extends WebTestBase { */ public static $modules = array('block'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Non default theme admin', @@ -29,7 +32,7 @@ public static function getInfo() { /** * Test non-default theme admin. */ - function testNonDefaultBlockAdmin() { + public function testNonDefaultBlockAdmin() { $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); $this->drupalLogin($admin_user); $new_theme = 'bartik'; diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php index ca906ea..123293f 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -26,7 +26,12 @@ class DisplayBlockTest extends ViewTestBase { * * @var array */ - public static $modules = array('node', 'block_test_views', 'test_page_test', 'contextual', 'views_ui'); + public static $modules = array( + 'node', + 'block_test_views', + 'test_page_test', + 'contextual', + 'views_ui'); /** * Views used by this test. @@ -35,6 +40,9 @@ class DisplayBlockTest extends ViewTestBase { */ public static $testViews = array('test_view_block', 'test_view_block2'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => ' Display: Block', @@ -43,6 +51,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); @@ -200,8 +211,8 @@ public function testViewsBlockForm() { // Place the same block again and make sure we have a new ID. $this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, array(), t('Save block')); $block = $storage->load('views_block__test_view_block_block_1_' . $i); - // This will only return a result if our new block has been created with the - // expected machine name. + // This will only return a result if our new block has been created with + // the expected machine name. $this->assertTrue(!empty($block), 'The expected block was loaded.'); } @@ -268,7 +279,9 @@ public function testBlockRendering() { * Tests the contextual links on a Views block. */ public function testBlockContextualLinks() { - $this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links', 'administer blocks'))); + $this->drupalLogin($this->drupalCreateUser(array( + 'administer views', + 'access contextual links', 'administer blocks'))); $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1'); $cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('cache' => array('max_age' => 3600))); $this->drupalGet('test-page'); diff --git a/core/modules/block/tests/Drupal/block/Tests/BlockBaseTest.php b/core/modules/block/tests/Drupal/block/Tests/BlockBaseTest.php index 913130b..3a5faff 100644 --- a/core/modules/block/tests/Drupal/block/Tests/BlockBaseTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/BlockBaseTest.php @@ -19,6 +19,9 @@ */ class BlockBaseTest extends UnitTestCase { + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Base plugin', @@ -30,7 +33,7 @@ public static function getInfo() { /** * Tests the machine name suggestion. * - * @see \Drupal\block\BlockBase::getMachineNameSuggestion(). + * @see \Drupal\block\BlockBase::getMachineNameSuggestion() */ public function testGetMachineNameSuggestion() { $transliteraton = $this->getMockBuilder('Drupal\Core\Transliteration\PHPTransliteration') @@ -48,7 +51,7 @@ public function testGetMachineNameSuggestion() { $this->assertEquals('adminlabel', $block_base->getMachineNameSuggestion()); // Test with more unicodes. - $definition = array('admin_label' =>'über åwesome', 'provider' => 'block_test'); + $definition = array('admin_label' => 'über åwesome', 'provider' => 'block_test'); $block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition); $this->assertEquals('uberawesome', $block_base->getMachineNameSuggestion()); } diff --git a/core/modules/block/tests/Drupal/block/Tests/BlockConfigEntityUnitTest.php b/core/modules/block/tests/Drupal/block/Tests/BlockConfigEntityUnitTest.php index 98d8d6d..1f264a0 100644 --- a/core/modules/block/tests/Drupal/block/Tests/BlockConfigEntityUnitTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/BlockConfigEntityUnitTest.php @@ -84,6 +84,8 @@ public function setUp() { } /** + * Tests the config entity dependency calculation. + * * @covers ::calculateDependencies */ public function testCalculateDependencies() { diff --git a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php index 760060b..fc2b2a2 100644 --- a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php @@ -17,6 +17,9 @@ */ class BlockFormControllerTest extends UnitTestCase { + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block form controller', @@ -45,7 +48,11 @@ public function testGetUniqueMachineName() { $query->expects($this->exactly(5)) ->method('execute') - ->will($this->returnValue(array('test', 'other_test', 'other_test_1', 'other_test_2'))); + ->will($this->returnValue(array( + 'test', + 'other_test', + 'other_test_1', + 'other_test_2'))); $block_storage = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface'); $block_storage->expects($this->exactly(5)) @@ -64,8 +71,8 @@ public function testGetUniqueMachineName() { $block_form_controller = new BlockFormController($entity_manager, $language_manager, $config_factory); - // Ensure that the block with just one other instance gets the next available - // name suggestion. + // Ensure that the block with just one other instance gets the next + // available name suggestion. $this->assertEquals('test_2', $block_form_controller->getUniqueMachineName($blocks['test'])); // Ensure that the block with already three instances (_0, _1, _2) gets the diff --git a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php index 5ff93f2..6da35b5 100644 --- a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php @@ -28,6 +28,9 @@ class CategoryAutocompleteTest extends UnitTestCase { */ protected $autocompleteController; + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block category autocomplete', @@ -36,6 +39,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ public function setUp() { $block_manager = $this->getMockBuilder('Drupal\block\Plugin\Type\BlockManager') ->disableOriginalConstructor() @@ -71,6 +77,7 @@ public function testAutocompleteSuggestions($string, $suggestions) { * Data provider for testAutocompleteSuggestions(). * * @return array + * An array of test autocomplete suggestions. */ public function providerTestAutocompleteSuggestions() { $test_parameters = array(); diff --git a/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php b/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php index bf7a3e4..e15b4c2 100644 --- a/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php @@ -18,6 +18,9 @@ */ class BlockLocalTasksTest extends LocalTaskIntegrationTest { + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Block local tasks test', @@ -26,13 +29,14 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ public function setUp() { $this->directoryList = array('block' => 'core/modules/block'); parent::setUp(); - $config_factory = $this->getConfigFactoryStub(array('system.theme' => array( - 'default' => 'test_c', - ))); + $config_factory = $this->getConfigFactoryStub(array('system.theme' => array('default' => 'test_c'))); $themes = array(); $themes['test_a'] = (object) array( @@ -82,8 +86,20 @@ public function testBlockAdminDisplay($route, $expected) { */ public function providerTestBlockAdminDisplay() { return array( - array('block.admin_display', array(array('block.admin_display'), array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'))), - array('block.admin_display_theme', array(array('block.admin_display'), array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'))), + array( + 'block.admin_display', + array( + array('block.admin_display'), + array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'), + ), + ), + array( + 'block.admin_display_theme', + array( + array('block.admin_display'), + array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'), + ), + ), ); } diff --git a/core/modules/block/tests/Drupal/block/Tests/Plugin/views/display/BlockTest.php b/core/modules/block/tests/Drupal/block/Tests/Plugin/views/display/BlockTest.php index 765cc57..a02e17f 100644 --- a/core/modules/block/tests/Drupal/block/Tests/Plugin/views/display/BlockTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/Plugin/views/display/BlockTest.php @@ -37,6 +37,9 @@ class BlockTest extends UnitTestCase { */ protected $blockDisplay; + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => ' Views: Display Block', diff --git a/core/modules/block/tests/modules/block_test/block_test.module b/core/modules/block/tests/modules/block_test/block_test.module index a527ae1..f985a42 100644 --- a/core/modules/block/tests/modules/block_test/block_test.module +++ b/core/modules/block/tests/modules/block_test/block_test.module @@ -2,7 +2,7 @@ /** * @file - * Provide test blocks. + * Provide test blocks. */ use Drupal\block\BlockPluginInterface; @@ -21,7 +21,7 @@ function block_test_block_alter(&$block_info) { */ function block_test_block_view_test_cache_alter(array &$build, BlockPluginInterface $block) { if (\Drupal::state()->get('block_test_view_alter_suffix') !== NULL) { - $build['#suffix'] = '
Goodbye!'; + $build['#suffix'] = '
Goodbye!'; } if (\Drupal::state()->get('block_test_view_alter_cache_key') !== NULL) { $build['#cache']['keys'][] = \Drupal::state()->get('block_test_view_alter_cache_key'); @@ -35,9 +35,9 @@ function block_test_block_view_test_cache_alter(array &$build, BlockPluginInterf } /** - * #pre_render callback for a block to alter its content. + * The #pre_render callback for a block to alter its content. */ function block_test_pre_render_alter_content($build) { - $build['#prefix'] = 'Hiya!
'; + $build['#prefix'] = 'Hiya!
'; return $build; }