Unit tests fail. Class 'org\bovigo\vfs\vfsStream' not found

Created on 15 October 2019, over 4 years ago
Updated 9 May 2023, about 1 year ago

Hi, I am running the unit tests for the Migrate Plus module, but 3 of the tests fail complaining about 'org\bovigo\vfs\vfsStream'.

Here i post the full error message for the tests:

There were 3 errors:

1) Drupal\Tests\migrate_plus\Unit\data_fetcher\FileTest::testFetchFile
Error: Class 'org\bovigo\vfs\vfsStream' not found

/modules/contrib/migrate_plus/tests/src/Unit/data_fetcher/FileTest.php:87

2) Drupal\Tests\migrate_plus\Unit\data_fetcher\FileTest::testFetchMultipleFiles
Error: Class 'org\bovigo\vfs\vfsStream' not found

/modules/contrib/migrate_plus/tests/src/Unit/data_fetcher/FileTest.php:87

3) Drupal\Tests\migrate_plus\Unit\data_fetcher\FileTest::testFetchUnreadableFile
Error: Class 'org\bovigo\vfs\vfsStream' not found

/modules/contrib/migrate_plus/tests/src/Unit/data_fetcher/FileTest.php:87

Possible solutions I see to that are:
* Check and skip the tests if vfsStream not found
* Add vfsStream as a dev dependency to have it installed doing a dev install

Not sure if adding the dependency is a good idea, for now i made a patch that checks for the class and skips the tests if not present. The patch was tested in my local machine with the expected behaviour.

New output

There were 3 skipped tests:

1) Drupal\Tests\migrate_plus\Unit\data_fetcher\FileTest::testFetchFile
vfsStream class not available. Please install composer package mikey179/vfsstream to run the tests

/modules/contrib/migrate_plus/tests/src/Unit/data_fetcher/FileTest.php:88

2) Drupal\Tests\migrate_plus\Unit\data_fetcher\FileTest::testFetchMultipleFiles
vfsStream class not available. Please install composer package mikey179/vfsstream to run the tests

/modules/contrib/migrate_plus/tests/src/Unit/data_fetcher/FileTest.php:88

3) Drupal\Tests\migrate_plus\Unit\data_fetcher\FileTest::testFetchUnreadableFile
vfsStream class not available. Please install composer package mikey179/vfsstream to run the tests

/modules/contrib/migrate_plus/tests/src/Unit/data_fetcher/FileTest.php:88

OK, but incomplete, skipped, or risky tests!
Tests: 262, Assertions: 551, Skipped: 3.
 [ExecStack] Done in 2.638s

T

πŸ› Bug report
Status

Needs work

Version

5.0

Component

Tests

Created by

πŸ‡ͺπŸ‡ΈSpain guiu.rocafort.ferrer Barcelona

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States trackleft2

    In case this helps anyone who prefers using lando for local development.

    name: migrate-tools
    recipe: drupal9
    config:
      php: '7.4'
      via: apache:2.4
      webroot: web
      database: mariadb:10.4
      xdebug: false
    services:
      # Replaces default lando MariaDB image with arm64 (Apple M1) compatible one.
      # TODO: remove database service overrides once lando is updated.
      database:
        type: compose
        services:
          image: mariadb:10.4
          command: docker-entrypoint.sh mariadbd
          restart: always
          ports:
            - '3306'
          environment:
            MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'true'
            MARIADB_DATABASE: drupal9
            MYSQL_DATABASE: drupal9
            MARIADB_USER: drupal9
            MARIADB_PASSWORD: drupal9
      appserver:
        overrides:
          environment:
            SIMPLETEST_DB: 'mysql://drupal9:drupal9@database/drupal9'
            SIMPLETEST_BASE_URL: 'http://appserver'
            MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--disable-dev-shm-usage","--headless","--no-sandbox"],"w3c":false}},"http://chromedriver:4444/wd/hub"]'
            XDEBUG_MODE: debug
          volumes:
            # Don't share our host working directory as /app. We want /app empty for composer.
            - /app
            # Instead share our host working directory as a standalone package.
            - .:/usr/local/migrate_tools
        build:
          - git clone --depth 1 --branch 9.4.5 https://github.com/drupal/recommended-project.git /app
          - composer config repositories.localdev path /usr/local/migrate_tools
          - composer require --no-update liuggio/fastest:1.11.0
          - composer require --no-update "behat/behat"
          - composer require --no-update "behat/mink:^1.8"
          - composer require --no-update "behat/mink-goutte-driver:^1.2"
          - composer require --no-update "behat/mink-selenium2-driver:^1.4"
          - composer require --no-update "phpspec/prophecy-phpunit:^2"
          - composer require --no-update "symfony/phpunit-bridge:^6.1"
          - composer require --no-update "mikey179/vfsstream"
          - composer require --no-update "phpunit/phpunit:^9.1"
          - composer require --no-update "drush/drush:>=11"
          - composer require --no-update "drupal/migrate_source_csv:>=3"
          - composer require --no-update "drupal/migrate_plus:>=5"
          - composer require --no-update drupal/migrate_tools:\*@dev
          - composer install
          - composer update
      chromedriver:
        type: compose
        services:
          image: seleniarm/standalone-chromium:4.1.4-20220429
          command: /opt/bin/entry_point.sh
    
    tooling:
      # Provide a command to install Drupal.
      install:
        service: appserver
        cmd:
          - /app/vendor/bin/drush --root=/app/web site:install --account-mail=noreply@example.com --account-name=admin --account-pass=admin --db-url=mysql://drupal9:drupal9@database:3306/drupal9 -y --verbose
          - /app/vendor/bin/drush en -y migrate_tools
    
      # Provide Drush tooling to automatically know the Drupal root.
      drush:
        service: appserver
        cmd: /app/vendor/bin/drush --root=/app/web
      phpunit:
        service: appserver
        cmd: /app/vendor/bin/phpunit --configuration /app/web/modules/contrib/migrate_tools/phpunit.xml.dist /app/web/modules/contrib/migrate_tools
    
    

    And the corresponding phpunit.xml.dist

    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="/app/web/core/tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
      <coverage processUncoveredFiles="true">
        <include>
          <directory>./modules</directory>
        </include>
        <exclude>
          <directory suffix="Test.php">./</directory>
          <directory suffix="TestBase.php">./</directory>
        </exclude>
      </coverage>
      <php>
        <!-- Set error reporting to E_ALL. -->
        <ini name="error_reporting" value="32767"/>
        <!-- Do not limit the amount of memory tests take to run. -->
        <ini name="memory_limit" value="-1"/>
      </php>
      <testsuites>
        <testsuite name="MigrateToolsTest">
          <directory>./tests</directory>
          <directory>./modules</directory>
        </testsuite>
      </testsuites>
      <!-- Filter for coverage reports. -->
    </phpunit>
    

    Once you have lando installed
    Inside the folder where you cloned a copy of migrate_tools run
    lando start
    lando install
    lando phpunit

    Which outputs

    ➜  migrate_tools git:(6.0.x) βœ— lando phpunit
    PHPUnit 9.6.7 by Sebastian Bergmann and contributors.
    
    ....................................                              36 / 36 (100%)
    
    Time: 00:59.423, Memory: 10.00 MB
    
    OK (36 tests, 328 assertions)
    
    
Production build 0.69.0 2024