Problem/Motivation

admin/structure/block/demo has no test coverage.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it adds tests.
Issue priority Normal because it adds a test for working but untested code.
Unfrozen changes Unfrozen because it only changes tests.

Proposed resolution

Add test coverage with different themes, including testing the default theme, and ensure the link for "Exit block region demonstration" uses "admin/structure/blocks"

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rosinegrean’s picture

Assigned: Unassigned » rosinegrean
rosinegrean’s picture

Status: Active » Needs review
FileSize
2.37 KB
tim.plunkett’s picture

Status: Needs review » Needs work

Great work @prics! Just a couple nits

  1. +++ b/core/modules/block/src/Tests/BlockTestDemo.php
    @@ -0,0 +1,65 @@
    + * Definition of Drupal\block\Tests\BlockTestDemo.
    

    This should be "Contains \Drupal" instead of "Definition of Drupal"

  2. +++ b/core/modules/block/src/Tests/BlockTestDemo.php
    @@ -0,0 +1,65 @@
    +class BlockTestDemo extends WebTestBase {
    

    Let's rename this BlockDemoTest (remember to change the @file part too)

  3. +++ b/core/modules/block/src/Tests/BlockTestDemo.php
    @@ -0,0 +1,65 @@
    +  function testBlockDemo() {
    

    Please make this public function testBlockDemo

  4. +++ b/core/modules/block/src/Tests/BlockTestDemo.php
    @@ -0,0 +1,65 @@
    +    $this->assertLinkByHref('admin/structure/block');
    

    This is correct, but can we add $this->assertNoLinkByHref('admin/structure/block/list/' . $default_theme); on the next line to be sure?

  5. +++ b/core/modules/block/src/Tests/BlockTestDemo.php
    @@ -0,0 +1,65 @@
    +    $this->assertLinkByHref('admin/structure/block');
    ...
    +    $this->assertLinkByHref('admin/structure/block');
    

    These should be asserting admin/structure/block/list/bartik for the first and admin/structure/block/list/seven for the second, not just the short path

rosinegrean’s picture

Status: Needs work » Needs review
FileSize
2.48 KB
skipyT’s picture

Status: Needs review » Needs work

Looks nice, only one thing spotted:

+++ b/core/modules/block/src/Tests/BlockDemoTest.php
@@ -0,0 +1,66 @@
+ * Contains of Drupal\block\Tests\BlockDemoTest.

This should be 'Contains \Drupal...' not 'Contains of Drupal'

rosinegrean’s picture

Status: Needs work » Needs review
FileSize
414 bytes
2.48 KB
skipyT’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/block/src/Tests/BlockDemoTest.php
@@ -0,0 +1,66 @@
+    // Install default theme and confirm we have access to the demo page for it.
+    $config = \Drupal::config('system.theme');
+    $default_theme = $config->get('default');
+    \Drupal::service('theme_handler')->install(array($default_theme));

The default theme is already installed.

+++ b/core/modules/block/src/Tests/BlockDemoTest.php
@@ -0,0 +1,66 @@
+    $edit['admin_theme'] = $default_theme;
+    $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
...
+    $edit['admin_theme'] = 'bartik';
+    $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
...
+    $edit['admin_theme'] = 'seven';
+    $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));

Why do we need to set the admin theme?

dstotijn’s picture

Status: Needs work » Needs review
FileSize
2.17 KB
2.87 KB

Updated patch from #6 based on comments from alexpott in #8. No need to install default theme. No need to set admin theme. Refactored code to loop through all available themes and perform assertions.

YesCT’s picture

Assigned: rosinegrean » Unassigned
wheatpenny’s picture

Issue summary: View changes

Added beta evaluation

joshi.rohit100’s picture

I think, we should use the short array synatx (as new patch policy).

lauriii queued 9: 2352791-9.patch for re-testing.

sam0971’s picture

I updated the patch with the short array syntax.

Status: Needs review » Needs work

The last submitted patch, 14: add_test_coverage_for-2352791-14.patch, failed testing.

The last submitted patch, 14: add_test_coverage_for-2352791-14.patch, failed testing.

sam0971’s picture

Updated the patch so it includes the whole file now.

sam0971’s picture

Hided the wrong patch.

sam0971’s picture

Status: Needs work » Needs review

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Status: Needs review » Needs work

Nice. Pretty sure this can be in 8.1.x because it's a test.

Restarting the testbot for the patch in #17. The test passes locally.

Here's a review:

  1. +++ b/core/modules/block/src/Tests/BlockDemoTest.php
    @@ -0,0 +1,67 @@
    +/**
    + * @file
    + * Contains \Drupal\block\Tests\BlockDemoTest.
    + */
    

    We don't do 'Contains' anymore, so remove the @file section.

  2. +++ b/core/modules/block/src/Tests/BlockDemoTest.php
    @@ -0,0 +1,67 @@
    +    $config = \Drupal::config('system.theme');
    

    Should be $this->container->get('config.factory')->get('system.theme');

  3. +++ b/core/modules/block/src/Tests/BlockDemoTest.php
    @@ -0,0 +1,67 @@
    +      \Drupal::service('theme_handler')->install([$theme]);
    

    Should be $this->container->get() instead of \Drupal::service().

The last submitted patch, 17: add_test_coverage_for-2352791-17.patch, failed testing.

ashishdalvi’s picture

Assigned: Unassigned » ashishdalvi
ashishdalvi’s picture

Status: Needs work » Needs review
FileSize
2.11 KB
1.23 KB

Hi Mile23,

Thanks for suggestions.

I have worked on changes mentioned above. Added patch and interdiff.

naveenvalecha’s picture

That's a F/R can we bump this to 8.2.x and directly write the BTB instead of WTB ?

mparker17’s picture

Assigned: ashishdalvi » Unassigned

Unassigning because no work has been done on it for almost 4 weeks. Also, I'm hoping that someone will be able to review this at the Drupal North 2016 code sprint tomorrow.

@Ashish.Dalvi, if you are still working on this issue, please re-assign it to yourself.

mparker17’s picture

Not sure what the abbreviation "BTB" means, but I think "F/R" = "Feature Request" and "WTB" = "Web Test Base".

Mile23’s picture

Right, BrowserTestBase and WebTestBase.

Not sure about what 'F/R' means because this isn't a feature request. Maybe @naveenvalecha can clarify.

It should be 8.1.x because it's a test improvement. The new test should pass both 8.1.x and 8.2.x.

naveenvalecha’s picture

@Mile23,
Yup F/R refers to the feature request.
however if its not a FR then its good to review.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ZeiP’s picture

Attached is a new patch with just one newline added for code style. Otherwise looked good.

naveenvalecha’s picture

ZeiP’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Looks good and works, marking RTBC.

  • catch committed f6df60e on 8.4.x
    Issue #2352791 by prics, sam0971, naveenvalecha, Ashish.Dalvi, dstotijn...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.4.x and cherry-picked to 8.3.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.