Instead of our current implementation of CTools style php code exports to create test views, we should bring this in line with how we create them now with our entity controller and config as storage. Here is an initial patch for this. It needs work, but alot of the work to convert these has been done.

Comments

dawehner’s picture

+++ b/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.phpundefined
@@ -202,34 +202,14 @@ class HandlerFieldFieldTest extends FieldTestBase {
+      $handler->display_handler->display->display_options['fields'][$field['field_name']]['id'] = $field['field_name'];
+      $handler->display_handler->display->display_options['fields'][$field['field_name']]['table'] = 'field_data_' . $field['field_name'];

$handler doesn't exist in this local scope ... you probably mean $view

+++ b/lib/Drupal/views/Tests/User/ArgumentValidateTest.phpundefined
@@ -87,34 +87,9 @@ class ArgumentValidateTest extends UserTestBase {
+  ¶

just some whitespace

+++ b/lib/Drupal/views/Tests/ViewTestBase.phpundefined
@@ -382,51 +383,27 @@ abstract class ViewTestBase extends WebTestBase {
+   * Creates a new View instance by loading config data and calling create
+   * instead of loading the view normally.

Even there is a 80 chars limit for the first sentence, it's not that important for me, because it describes detailed what the function does.

+++ b/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.phpundefined
@@ -202,34 +202,14 @@ class HandlerFieldFieldTest extends FieldTestBase {
+      $handler->display_handler->display->display_options['fields'][$field['field_name']]['id'] = $field['field_name'];
+      $handler->display_handler->display->display_options['fields'][$field['field_name']]['table'] = 'field_data_' . $field['field_name'];

$handler doesn't exist in this local scope ... you probably mean $view

damiankloip’s picture

Status: Active » Needs review
StatusFileSize
new0 bytes

Thanks @dawehner, I have made those changes. I don't expect this to pass, but we might as well get an idea of where we are.

damiankloip’s picture

StatusFileSize
new138.27 KB

Oh god, sorry. --cached is usually good for added files.

Status: Needs review » Needs work

The last submitted patch, 1771944-3.patch, failed testing.

aspilicious’s picture

Status: Needs work » Needs review

Some of these files have that weird
core: '8' VS core: { } and human_name: '' VS human_name: { }mixup.

Why does views have so many api versions!

damiankloip’s picture

Hmm, all of these were exported directly from the instantiated classes the the original exports provide. We need to look at that one, because I think they all started life as '8' when I started this patch?

tim.plunkett’s picture

The human_name: {} and tag: {} are causing most of these failures.
Also, views.view.test_view_fieldapi.yml doesn't exist?

So, we have tests/views_test/config and tests/default_views now? Why not just use the first one?

damiankloip’s picture

I think you are right, we're also dependent on #1772146: Clean up properties on View object (and add default values), as that will get rid of these bogus arrays when exporting anyway.

The new folder was something me and dawehner discussed, then we can lose the dependency on the views_test module, unless we keep everything in that folder and load them basically as they are now?

dawehner’s picture

So, we have tests/views_test/config and tests/default_views now? Why not just use the first one?

We have two seperate use cases for now. First: Use the views in the UI, second: use the views in API.
If we put all into the config directory basically all tests would require the views_test module to be enabled (you worked so hard to get rid of it if possible).

If we put everything into the default_views folder, we cannot any longer directly use that in the ui, though one thing what we could do
is to load and save the view and then start to edit the view.

tim.plunkett’s picture

It's weird seeing them not in a /config folder.
Another possibility is having an empty test module like 'views_test_config' only to contain these, that can be enabled in the usual way with public static $modules, and rename views_test to views_test_data.

dawehner’s picture

Oh i like the suggestion of tim. What about doing views_test_views instead of views_test_data?

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

Okay, going to work on this.

tim.plunkett’s picture

StatusFileSize
new161.55 KB

Okay, here's an attempt to fix this all up.

I was able to really clean up createViewFromConfig() now that views_test_config is a real module.

tim.plunkett’s picture

StatusFileSize
new43.12 KB

And the interdiff.

tim.plunkett’s picture

StatusFileSize
new557 bytes
new161.89 KB

Duh!

tim.plunkett’s picture

Title: Replace exported views in tests with config files. » Replace exported views in tests with config files
StatusFileSize
new423 bytes
new162.18 KB

Oh wow. Fun with stupid bugs!

tim.plunkett’s picture

Status: Needs review » Needs work
StatusFileSize
new162.21 KB

This was a bug in the original patch.

tim.plunkett’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

StatusFileSize
new163.67 KB
new3.58 KB

Fixed more failures.

tim.plunkett’s picture

StatusFileSize
new2.86 KB
new166.25 KB

Even more.

tim.plunkett’s picture

StatusFileSize
new4.62 KB
new166.79 KB

More fixes.

tim.plunkett’s picture

StatusFileSize
new166.81 KB

Less fails.

tim.plunkett’s picture

StatusFileSize
new168.1 KB

3 more fixes

Status: Needs review » Needs work

The last submitted patch, views-1771944-31.patch, failed testing.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

Alright, I've had enough :)

Someone else will have to finish off those failures.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new12.49 KB
new172.24 KB

Some of the tests could be fixed by adding ->cloneView() but sadly i don't really understand why this helps in most cases.
For the translatable text for example unpackOptions might have changed the values already so unpackTranslatables might have a different result.

Please don't trust the interdiff that much, as it contains git-crap.

tim.plunkett’s picture

StatusFileSize
new7.79 KB
new173.25 KB

I think I understand why cloneView is necessary, but it's not optimal. I opened #1773778: Standardize on using $this->view in setUp(), $this->view->destroy in tearDown() as a follow-up.

Here's a different take on #34, with an interdiff against #31.

Status: Needs review » Needs work

The last submitted patch, views-1771944-35.patch, failed testing.

tim.plunkett’s picture

Shit, those failures are in HEAD.
http://qa.drupal.org/pifr/test/273938

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new196.81 KB

Hopefully the last patch.

tim.plunkett’s picture

StatusFileSize
new219.81 KB

Famous last words.

tim.plunkett’s picture

StatusFileSize
new219.84 KB
tim.plunkett’s picture

StatusFileSize
new220.43 KB

Fixed those locally

tim.plunkett’s picture

StatusFileSize
new221.43 KB

Final tweaks. If this passes, please commit!

tim.plunkett’s picture

Status: Needs review » Needs work

The last submitted patch, views-1771944-46.patch, failed testing.

tim.plunkett’s picture

StatusFileSize
new220.81 KB

Removed the offending changes.

tim.plunkett’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, views-1771944-49.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new221.06 KB

Tracked down the last bug.

Because both @damiankloip and I put in substantial time into this issue, I have a feature branch I'd like to merge in. I'll do that once it's RTBC by one of the VDC team.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Awesome!

tim.plunkett’s picture

Status: Reviewed & tested by the community » Fixed

Merged in! Whew, what a day.

damiankloip’s picture

This makes me happy :) Great work!

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