Tests are failing in both the 8.x-1.x-dev and the rc1 versions with the following error:

Behat\Mink\Exception\ResponseTextException : The text "First" was not found anywhere in the text of the current page.

in state_machine/tests/src/Functional/StateTransitionFormTest.php:56

This happens because the views.view.state_machine_test.yml is not imported and the

$this->drupalGet('/state-machine-test');

returns a page not found.

I see two other patches fail due to this issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

idimopoulos created an issue. See original summary.

idimopoulos’s picture

I do not know how the test was merged in https://www.drupal.org/project/state_machine/issues/3012285 since the source of the issue seems to be due to core since 8.0.
The failing test derives from the fact that the view itself is not imported but it does not throw any errors. Digging a bit more on what happens when a module is installed, it seems the process ends up in \Drupal\Core\Config\ConfigInstaller::createConfiguration where it loads the appropriate Entity class from the configuration file and attempts to create and store an entity with the given values.
That leads to line 363 of that file where it is checked if the entity is installable (if ($entity->isInstallable()) {).
For a view entity, the \Drupal\views\Entity\View::isInstallable is gathering the views data from all entities and checks if the base table declared in the view exists.
So the main problem is the main table. For the StateTransitionFormTest, the EntityTestWithBundle test content entity is used.
This entity, in its definition PHPDocBlock has the following:

 *   base_table = "entity_test_with_bundle",
 *   data_table = "entity_test_with_bundle_field_data",
 *   admin_permission = "administer entity_test_with_bundle content",
 *   persistent_cache = FALSE,
 *   translatable = TRUE,

The translatable here is very important as, during the construction of the views data, there is a distinction between the base_table and data_table.
In \Drupal\views\EntityViewsData::getViewsData, the following check is performed

    $base_table = $this->entityType->getBaseTable() ?: $this->entityType->id();
    .
    .
    $data_table = '';
    if ($translatable) {
      $data_table = $this->entityType->getDataTable() ?: $this->entityType->id() . '_field_data';
    }

which overrides the base table with the data table, which means that the base table for the views is not entity_test_with_bundle but entity_test_with_bundle_field_data.
The same applies for all base properties in the view. So the label requested should be

          name:
          table: entity_test_with_bundle_field_data
          field: name
          id: name

(the table of the property should also point on the data table).

This also is consistent with the rest of the translatable entities, like node, where I exported a single view and it contains

.
.
id: content
label: Content
base_table: node_field_data
base_field: nid
core: 8.x

I am attaching a patch to fix the views and allow the tests to be green again as the patches fail all over. Again, How was this merged if it was not tested? Accident?

idimopoulos’s picture

Status: Active » Needs review
idimopoulos’s picture

Sorry, empty patch provided before. I accidentally created it without committing the changes so it was blank. Providing the correct patch now.

alonaoneill’s picture

Patch applied!
Not sure what was wrong before.

Neograph734’s picture

Status: Needs review » Reviewed & tested by the community

I do not know how the test was merged in https://www.drupal.org/project/state_machine/issues/3012285 since the source of the issue seems to be due to core since 8.0.

EntityTestWithBundle was changed 2 months ago in https://git.drupalcode.org/project/drupal/commit/46424a8

 *     },
 *   },
 *   base_table = "entity_test_with_bundle",
+ *   data_table = "entity_test_with_bundle_field_data",
 *   admin_permission = "administer entity_test_with_bundle content",
 *   persistent_cache = FALSE,
+ *   translatable = TRUE,
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid"
jungle’s picture

Confirm that tests passed on my local

PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

Testing modules/contrib/state_machine/
.....................                                             21 / 21 (100%)

Time: 44.49 seconds, Memory: 12.00MB

OK (21 tests, 142 assertions)

  • bojanz committed c197fa3 on 8.x-1.x authored by idimopoulos
    Issue #3058938 by idimopoulos, Neograph734: Tests are broken
    
bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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