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

[BUG] [PDOException] Field 'post_mime_type' doesn't have a default value #548

Closed LucasDemea closed 2 years ago

LucasDemea commented 2 years ago

Environment OS: Ubuntu 20.04.03 PHP version: 7.4 Installed Codeception version: [e.g. 2.5.0]
Installed wp-browser version: 3.0.14 WordPress version: 5.8.2 Local development environment: Vagrant VM running ubuntu 20.04 WordPress structure and management: Bedrock

Can you perform the test manually? Not applicable

Codeception configuration file
Paste, in a fenced YAML block, the content of your Codeception configuration file; remove any sensitive data!

paths:
  tests: tests
  output: tests/_output
  data: tests/_data
  support: tests/_support
  envs: tests/_envs

# bootstrap: "../web/wp-config.php" # relative to tests/
actor_suffix: Tester
extensions:
  enabled:
    - Codeception\Extension\RunFailed
  commands:
    - Codeception\Command\GenerateWPUnit
    - Codeception\Command\GenerateWPRestApi
    - Codeception\Command\GenerateWPRestController
    - Codeception\Command\GenerateWPRestPostTypeController
    - Codeception\Command\GenerateWPAjax
    - Codeception\Command\GenerateWPCanonical
    - Codeception\Command\GenerateWPXMLRPC
params:
  - .env.testing

Suite configuration file Paste, in a fenced YAML block, the content of the suite configuration file; remove any sensitive data!

# Codeception Test Suite Configuration

# suite for acceptance tests.
# perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

actor: AcceptanceTester
extensions:
  enabled:
    - Codeception\Extension\Recorder:
  config:
    Codeception\Extension\Recorder:
      delete_successful: false
      # delete_orphaned: true
      module: WPWebDriver
modules:
  enabled:
    - WPDb # BEFORE the WPLoader one!
    # - WPLoader # AFTER the WPDb one!
    - WPWebDriver
    - WPFilesystem
    - \Helper\Acceptance
  config:
    WPDb:
      dsn: "%DB_DSN%"
      user: "%DB_USER%"
      password: "%DB_PASSWORD%"
      dump: "tests/_data/dump.sql"
      #import the dump before the tests; this means the test site database will be repopulated before the tests.
      populate: true
      # re-import the dump between tests; this means the test site database will be repopulated between the tests.
      cleanup: true
      waitlock: 10
      url: "%WP_URL%"
      urlReplacement: false # leads to corrupted db if original url is found in serialized data. URL is read from .env anyway
      originalUrl: "%ORIGINAL_URL%"
      tablePrefix: "%DB_PREFIX%"
      populator: "mysql -u $user -h $host --password=$password $dbname < $dump"
    WPWebDriver:
      url: "%WP_URL%"
      adminUsername: "%ADMIN_USERNAME%"
      adminPassword: "%ADMIN_PASSWORD%"
      adminPath: "%WP_ADMIN_PATH%"
      window_size: 1440x900
      port: 4444
      browser: chrome
      start: true
      capabilities:
        # Used in more recent releases of Selenium.
        "goog:chromeOptions":
          args:
            [
              "--headless",
              "--no-sandbox",
              "--disable-gpu",
              "allow-insecure-localhost",
              "--ignore-certificate-errors",
              "--disable-dev-shm-usage",
              "--user-agent=wp-browser",
            ]
    WPFilesystem:
      wpRootFolder: "%WP_ROOT_FOLDER%"
      plugins: "../app/plugins"
      mu-plugins: "../app/mu-plugins"
      themes: "../app/themes"
      uploads: "../app/uploads"

Describe the bug When using WPDb and the specific havePostInDatabase(), i'm running in a [PDOException] SQLSTATE[HY000]: General error: 1364 Field 'post_mime_type' doesn't have a default value error on a certain site i'm maintaining.

Output

PostEditCest: Edit a post
Signature: PostEditCest:tryToTest
Test: tests/acceptance/PostEditCest.php:tryToTest
Scenario --
  [Db] Executing Populator: `mysql -u wordpress -h localhost --password=wordpress tests < tests/_data/dump.sql`
  [Db] Populator Finished.
  [Query] INSERT INTO `lmrsr_options` (`option_name`, `option_value`, `autoload`) VALUES (?, ?, ?)
  [Parameters] ["admin_email_lifespan",2533080438,"yes"]
  [Query] INSERT INTO `lmrsr_options` (`option_name`, `option_value`, `autoload`) VALUES (?, ?, ?)
  [Parameters] ["_transient_doing_cron",1638549821,"yes"]
 I am on page "/wp/login-admin"
  [GET] http://girci.test/wp/login-admin
 I fill field "#user_login","******"
 I fill field "#user_pass","******"
 I click "#wp-submit"
 I see element "#adminmenu"
 I have post in database 
  [Query] SELECT ID FROM lmrsr_posts ORDER BY ID DESC LIMIT 1
  [Query] INSERT INTO `lmrsr_posts` (`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  [Parameters] [1,"2021-12-03 17:34:54","2021-12-03 16:34:54","Post 3951 content","Post 3951 title","Post 3951 excerpt","publish","open","open","","post-3951-title","","","2021-12-03 17:34:54","2021-12-03 16:34:54","",0,"http://girci.test/?p=3951",0,"post"]
  Screenshot and page source were saved into '/srv/www/girci/current/tests/_output/' dir
 ERROR

To Reproduce Run a test with the $I->havePostInDatabase(); step

LucasDemea commented 2 years ago

If found where this was coming from and it is not related to wp-browser: for some reason my database tables had lost their DEFAULT value...