Closed truckee closed 7 years ago
It would be nice to know whether the failure is due to an error of configuration or in the code. All I've been able to demonstrate so far is that the failure is independent of OS (Ubuntu or Windows), running from command line or in Netbeans. It is certainly true that if tables are defined in the test database they are dropped before this error is thrown.
Thanks for reporting the issue,
could you post the configuration file of the suite you are using? How did you generate the SQL dump file?
site
and blogs
are multisite installation tables; WPDb will try to replace the hard-coded site URL that's in the database dump with the one defined in its configuration, those are just messages and not errors.
Having the same issue, since after updating wp-browser this is now broken, but used to work fine before.
Here's an example config we're using for a functional test suite.
# Codeception Test Suite Configuration
# Suite for WordPress functional tests.
# Emulate web requests and make the WordPress application process them.
class_name: FunctionalTester
modules:
enabled:
- \Helper\Functional
- Filesystem
- WPDb
- WordPress
config:
WPDb:
dsn: "mysql:host=mysql;dbname=foobar_test"
user: root
password: ""
dump: tests/_data/dump.sql
populate: true
cleanup: true
reconnect: true
url: 'http://foobar.dev'
urlReplacement: true
tablePrefix: wp_
WordPress:
depends: WPDb
wpRootFolder: public
adminUsername: admin
adminPassword: test
functional.suite.yml:
actor: FunctionalTester
modules:
enabled:
- WPDb
- WordPress
- Asserts
- \Helper\Functional
config:
WPDb:
dsn: 'mysql:host=localhost;dbname=wptests'
user: 'root'
password: '********'
dump: 'tests/_data/dump.sql'
populate: true
cleanup: true
url: 'http://uufnn'
urlReplacement: true
tablePrefix: 'wp_'
WordPress:
depends: WPDb
wpRootFolder: 'G:/Documents/workspace/uufnn'
adminUsername: 'gbrooks'
adminPassword: '********'
adminPath: '/wp-admin'
Ubuntu environment is similar
I've tried two different dump files. One was a dump from an existing WordPress sandbox with siteurl
and home
fields modified to match the test environment. The other was just the structure from the sandbox site.
I've not forgotten the issue but I'm having issues with my working machine and cannot code really efficiently. I will get back on this as soon as possible. Thanks for your feedback.
No worries. Glad I'm not the only one to whom "issues" happen!
I've got a branch out that might fix the issue, could you try pulling it using:
composer require --dev lucatume/wp-browser:dev-wpdb-sql-dump-fix
Here's the result of the command .\vendor\bin\codecept run functional
:
Stack trace:
#0 G:\Documents\workspace\uufnn\wp-includes\wp-db.php(658): wpdb->db_connect()
#1 G:\Documents\workspace\uufnn\wp-includes\load.php(404): wpdb->__construct('root', '********', 'uufnn-wp', '127.0.0.1')
#2 G:\Documents\workspace\uufnn\wp-settings.php(106): require_wp_db()
#3 G:\Documents\workspace\uufnn\wp-config.php(90): require_once('G:\\Documents\\wo...')
#4 G:\Documents\workspace\uufnn\wp-load.php(37): require_once('G:\\Documents\\wo...')
#5 G:\Documents\workspace\uufnn\wp-blog-header.php(13): require_once('G:\\Documents\\wo...')
#6 G:\Documents\workspace\uufnn\index.php(17): require('G:\\Documents\\wo...')
#7 G:\Documents\workspace\uufnn\wp-content\plugins\rma\vendor\lucatume\wp-browser\src\tad\scripts\request.php(29): include('G:\\Documents\\wo...')
#8 {main}
thrown in G:\Documents\workspace\uufnn\wp-includes\wp-db.php on line 1568
[mysql_connect]...This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
Environment is Windows 10 Pro 64-bit, build 1703, PHP 7.1.6, Apache 2.4.25. I imagine by VM will fly with PHP 5.6.
Guess I need to go backwards? Not a fan of going back, especially 'cuz the project is for a site that's on PHP 7.0 now. Please advise.
On VM with PHP 5.5.9, the test hangs. Do you have any suggestions on how to get useful feedback out of this?
try running the tests with -vvv
(activating the maximum level of verbosity) at the end
e.g.
vendor/bin/codecept run functional -vvv
On VM, I get screens of:
Tried to replace WordPress site domain but dump file does not contain a table INSERT instruction for table [blogs].
Tried to replace WordPress site domain but dump file does not contain a table INSERT instruction for table [site].
I've pushed a fix that should take care of the excess output on the same branch.
The "hanging" of the machine surprises me though: how big is the SQL dump you are trying to load?
As per the deprecated error: that's generated from the wp-db.php
class but I never got it. Running WordPress on PHP 7.1 yields no error.
The dump is sizable: ~3M. I'll trim it to see what happens when I can get back to this. Off now. I'll let you know how it goes.
Mmm, ok. The WPDb module, as the Db module it extends, is meant to load small initial dumps. For a dump that size use the populator to go from a PHP based import to a CLI based one: see here.
Pulled the latest, added populator and got this, where the 301 repeats:
$ ./vendor/bin/codecept run functional -vvv
Codeception PHP Testing Framework v2.3.3
Powered by PHPUnit 4.8.35 by Sebastian Bergmann and contributors.
[Db] Executing Populator: `mysql -u root -h localhost -p******** wpTests < tests/_data/full_site_dump.sql`
[Db] Populator Finished.
Rebuilding FunctionalTester...
[Db] Connected to wpTests
[Db] Executing Populator: `mysql -u root -h localhost -p******** wpTests < tests/_data/full_site_dump.sql`
[Db] Populator Finished.
Functional Tests (1) ----------------------------------------------------------------------------------------------------------------------------------------
Modules: WPDb, WordPress, Asserts, \Helper\Functional
-------------------------------------------------------------------------------------------------------------------------------------------------------------
HomePageCept: Check home page
Signature: HomePageCept
Test: tests/functional/HomePageCept.php
Scenario --
I am on page "/"
[Cookie Jar] ["wordpress_test_cookie=WP+Cookie+check; path=/; httponly"]
[Request Headers] []
[Page] /
[Response] 301
[Request Cookies] {"wordpress_test_cookie":"WP Cookie check"}
[Response Headers] {"Location":"http://rmasite.wp/","Content-type":"text/html; charset=UTF-8","Set-Cookie":["wordpress_test_cookie=WP Cookie check"]}
[Redirecting to] http://rmasite.wp/
[Page] http://rmasite.wp/
[Response] 301
[Request Cookies] {"wordpress_test_cookie":"WP Cookie check"}
[Response Headers] {"Location":"http://rmasite.wp/","Content-type":"text/html; charset=UTF-8","Set-Cookie":["wordpress_test_cookie=WP Cookie check"]}
[Redirecting to] http://rmasite.wp/
[Page] http://rmasite.wp/
[Response] 301
...
Ok, then the database issue is solved.
The 301 redirection seems to be a looping redirection issue that's not related to the database issue at hand.
To debug this: could you try using the WPBrowser
module in place of the WordPress
one to visit the page?
Without access to the site code and database I have little material to go by.
Ah, but you found the solution. By replacing WordPress
with WPBrowser
and its configuration I get (with much gratitude!):
$ ./vendor/bin/codecept run functional
Codeception PHP Testing Framework v2.3.3
Powered by PHPUnit 4.8.35 by Sebastian Bergmann and contributors.
Functional Tests (1) ----------------------------------------------------------------------------------------------------------------------------------------
✔ HomePageCept: Check home page (0.11s)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 859 ms, Memory: 24.75MB
OK (1 test, 1 assertion)
You are more than welcome but I fear we just found another bug. That 301 loop is a WordPress module bug I'm tracking in a separate issue (https://github.com/lucatume/wp-browser/issues/85)
Thanks for reporting the issue (the original one and the new one) and the patience.
Closing this.
This is a redirect from Codeception issues.
Error message & stack trace below. Database is expected to include a table named
options
? What are [blogs] and [site]?HomePageCept.php
$ composer show