Updated: Comment 0

Problem/Motivation

Proposed resolution

Remaining tasks

User interface changes

API changes

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new32.71 KB

.

damiankloip’s picture

  1. +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsDataTest.php
    @@ -0,0 +1,477 @@
    +   * Stores a mocked module manager to invoke hooks.
    

    Maybe just 'The mocked module handler'.

  2. +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsDataTest.php
    @@ -0,0 +1,477 @@
    +   * $the mocked config factory.
    

    s/$the/The - unless you know something I don't about using variables in docs.. ;)

  3. +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsDataTest.php
    @@ -0,0 +1,477 @@
    +  public static function getInfo() {
    ...
    +  protected function setUp() {
    

    I *think* we put {@inheritdoc} here now?

  4. +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsDataTest.php
    @@ -0,0 +1,477 @@
    +    // \Drupal\views\ViewsDataHelper::fetchFields().
    

    @see ?

  5. +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsDataTest.php
    @@ -0,0 +1,477 @@
    +    $this->assertEquals(2, count($base_tables), 'The correct amount of base tables were returned.');
    

    We can use assertCount() here instead.

  6. +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsDataTest.php
    @@ -0,0 +1,477 @@
    +    $this->assertEquals($expected_views_data, $views_data);
    ...
    +    $this->assertEquals($expected_views_data, $views_data);
    ...
    +    $this->assertEquals(array(), $views_data);
    ...
    +    $this->assertEquals($expected_views_data, $views_data);
    ...
    +    $this->assertEquals($expected_views_data, $views_data);
    

    Do you think we should make these array comparison ones assertSame() ?

  7. +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsDataTest.php
    @@ -0,0 +1,477 @@
    +    $this->assertTrue(isset($views_data[$table_name]), 'Make sure the views_test_data info appears in the total views data.');
    

    assertArrayHasKey() can be used here.

dawehner’s picture

StatusFileSize
new32.65 KB

Thank you for the review!!

dawehner’s picture

StatusFileSize
new8.9 KB

.

tim.plunkett’s picture

StatusFileSize
new33.15 KB
new2.3 KB

I noticed that the coverage for fetchBaseTables() was incomplete, and realized that the test data was declaring the weight wrong. I decided to expand it to test all paths of the sort.

In addition, I think we've actually proven that the "If the key is invalid, return an empty array." case is unreachable code.
I cannot figure out how to arrive at that line. Either it is populated via cache, or we have $this->storage[$key] = array();.

Yay unit tests leading to removing dead code!

tim.plunkett’s picture

StatusFileSize
new566 bytes
new33.19 KB

Actually, I meant take that one step further.

dawehner’s picture

Oh yeah I was worried that I could not test that line.

damiankloip’s picture

StatusFileSize
new7.26 KB
new36.38 KB

Sorry to add another chef to the kitchen here, but I really couldn't be bothered to write this down, easier to just do it. Probably same as Tim above :)

I think we should setup the mock expectations for the cache backend in some of the other test methods, as they cover cases that are not covered below by the warmCache* methods. Like calling get(), then get($table_name), then get($random_table_name).

Oh, and brought back the -50 weight, so the fetchTables gets testing with a lower and higher weight, as well as a lower/higher title. So that should exercise the sorting.

dawehner’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Great improvements!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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