lucatume / wp-browser

The easy and reliable way to test WordPress with Codeception. 10 years of proven success.
https://wpbrowser.wptestkit.dev/
MIT License
603 stars 86 forks source link

Detecting wrong version of PHPUnit #241

Closed halmos closed 5 years ago

halmos commented 5 years ago

Environment OS: Mac PHP version: 7.2 Installed Codeception version:3.0.1 Installed wp-browser version: 2.2.8 WordPress version:5.2 Local development environment: Local by Flywheel WordPress structure and management: default

Did you use the codecept init wpbrowser command? yes

Did you take a look at Codeception and wp-browser documentation? yes

Codeception configuration file If you were able to complete the setup then paste, in a fenced YAML block, the content of your Codeception configuration file; remove any sensible data!

paths:
  tests: tests
  output: tests/_output
  data: tests/_data
  support: tests/_support
  envs: tests/_envs
actor_suffix: Tester
extensions:
  enabled:
    - Codeception\Extension\RunFailed
    - tad\WPBrowser\Extension\Symlinker
  commands:
    - Codeception\Command\GenerateWPUnit
    - Codeception\Command\GenerateWPRestApi
    - Codeception\Command\GenerateWPRestController
    - Codeception\Command\GenerateWPRestPostTypeController
    - Codeception\Command\GenerateWPAjax
    - Codeception\Command\GenerateWPCanonical
    - Codeception\Command\GenerateWPXMLRPC
  config:
    tad\WPBrowser\Extension\Symlinker:
      mode: theme
      destination: [local theme dev dir]
      rootFolder: [wp-content theme dir]
params:
  - .env.testing

Suite configuration file If you're encountering an issue with a specific suite, please provide its configuration file.

# Codeception Test Suite Configuration
#
# Suite for unit or integration tests that require WordPress functions and classes.

actor: WpunitTester
modules:
  enabled:
    - WPDb
    - WPLoader
    - \Helper\Wpunit
  config:
    WPDb:
      dsn: "mysql:host=%TEST_SITE_DB_HOST%;dbname=%TEST_SITE_DB_NAME%"
      user: "%TEST_SITE_DB_USER%"
      password: "%TEST_SITE_DB_PASSWORD%"
      #dump: "tests/_data/dump.sql"
      populate: false
      cleanup: false
      waitlock: 10
      url: "%WP_URL%"
      urlReplacement: true
      tablePrefix: "%TEST_SITE_TABLE_PREFIX%"
    WPLoader:
      wpRootFolder: "%WP_ROOT_FOLDER%"
      dbName: "%TEST_DB_NAME%"
      dbHost: "%TEST_DB_HOST%"
      dbUser: "%TEST_DB_USER%"
      dbPassword: "%TEST_DB_PASSWORD%"
      tablePrefix: "%TEST_TABLE_PREFIX%"
      domain: "%TEST_SITE_WP_DOMAIN%"
      adminEmail: "%TEST_SITE_ADMIN_EMAIL%"
      title: "Library Stack Testing"
      theme: artxt
      plugins: [""]
      activatePlugins: [""]
      loadOnly: true

Describe the issue you're encountering WPBrowser seems to be loading the TestCase for phpunit version < v8 (ie base) despite fact that phpunit version is 8.1.5

Output

Codeception PHP Testing Framework v3.0.1
Powered by PHPUnit 8.1.5 by Sebastian Bergmann and contributors.
Running with seed: 

  [Connecting To Db] {"config":{"tablePrefix":"wp_","populate":false,"cleanup":false,"reconnect":false,"dump":null,"populator":null,"urlReplacement":true,"waitlock":10,"dsn":"mysql:host=192.168.95.100:4014;dbname=local","user":"root","password":"root","url":"%WP_URL%"},"options":[]}
  [Db] Connected to default local
  WPLoader module will load WordPress when all other modules initialized.
  Running as single site

Fatal error: Declaration of myTest::setUp() must be compatible with tad\WPBrowser\Compat\PHPUnit\Testcase::setUp(): void in myTest.php on line 4
halmos commented 5 years ago

actually, it looks like it's just a minor issue with the generate:wpunit command. The skeleton code needs to be updated for phpunit v8 so that the methods have a void return type set. ie public function setUp() -> public function setUp() : void

lucatume commented 5 years ago

Thanks for reporting the issue and thanks for providing a possible fix. I will look into this next and push a fix.