Comments (8)
I have no experience with pods but being able to make integration tests with it seems a worthy achievement.
The module to use is WPLoader
(WordPress
is for functional testing and WPBootstrapper
for some edge acceptance cases) and it comes with a degree of customization that allowed it, up to this point, to test anything; should this not be the case I'm more than willing to look into it and solve the issue.
I've put up a demo repository where I'm running integration tests using the WPLoader
module on a theme relying on pods so that we can have an informed discussion.
from wp-browser.
that constant is defined in the the bootstrap file; is that file being included?
My guess is you are extending the \Codeception\TestCase\WPTestCase
(generated with the command) and using it in real unit tests.
That test case is meant to be used together with the WPLoader
module in integration tests that will load WordPress before the tests: is the WPLoader
module configured and loaded in your unit
suite?
from wp-browser.
Re constant & bootstrap, I don't see any _bootstrap.php file being populated.
I noticed that when I run except bootstrap, I receive an error about Wordpress location not being where expected and the bootstrap then seems to fail, the same goes for wpcept build
wpcept bootstrap
bin/wpcept bootstrap
Initializing Codeception in /usr/share/nginx/html/htdocs/content/themes/my-theme
File codeception.yml created <- global configuration
tests/unit created <- unit tests
tests/unit.suite.yml written <- unit tests suite configuration
tests/integration created <- integration tests
tests/integration.suite.yml written <- integration tests suite configuration
tests/functional created <- functional tests
tests/functional.suite.yml written <- functional tests suite configuration
tests/acceptance created <- acceptance tests
tests/acceptance.suite.yml written <- acceptance tests suite configuration
tests/_output was added to .gitignore
---
tests/_bootstrap.php written <- global bootstrap file
Building initial Tester classes
Building Actor classes for suites: acceptance, functional, integration, unit
-> AcceptanceTesterActions.php generated successfully. 0 methods added
\AcceptanceTester includes modules: \Helper\Acceptance, WPBrowser
[Codeception\Exception\ModuleConfigException]
WordPress module is not configured!
The path `/var/www/wordpress` is not pointing to a valid WordPress installation folder.
bootstrap [-ns|--namespace [NAMESPACE]] [-a|--actor [ACTOR]] [-e|--empty] [--] [<path>]
wpcept build
bin/wpcept build
Building Actor classes for suites: acceptance, functional, integration, unit
-> AcceptanceTesterActions.php generated successfully. 0 methods added
\AcceptanceTester includes modules: \Helper\Acceptance, WPBrowser
[Codeception\Exception\ModuleConfigException]
WordPress module is not configured!
The path `/var/www/wordpress` is not pointing to a valid WordPress installation folder.
build
Yes, I was trying to use WPTestCase
in unit tests, however I was using the WPBootstrapper
module to try and access methods provided by other plugins.
from wp-browser.
To clarify, here's my current setup and what I'm trying to achieve.
- I have a local wordpress installation with a development db loaded.
- I have a theme with various methods which I need to perform integration tests against.
- Many methods make use of a separate plugin (http://pods.io) to read and write to the database.
- I need to be able to run my tests against my local setup (
WPLoader
seems incompatible here), have access to the plugin specified as well as all WP functions within my integration tests.
I first tried using the WPBootstrapper
, but this didn't give me access to the plugin and it's functions (do I need to load plugins which are already enabled in my local WP setup?), so I just tried WordPress
, this again doesn't give me access to the plugin functions, but I also couldn't call any WP functions either ( activate_plugin() returned [Error] Call to undefined function activate_plugin()
).
Any suggestions on where I'm going wrong? Thanks
from wp-browser.
Excellent, thanks I'll take a look at this in the coming days.
I wonder if my issue calling any core WP functions relates to me using the Themosis framework (http://framework.themosis.com) changes the directory layout, installs WP into a sub dir and adds additional bootstrapping to the WP process.
For example, to get an integration test to run, I had to point my WPLoader root url at htdocs/cms/
(a sub dir within theists that contains the wp installation), but I was then unable to actually all any WP functions, which suggests that it isn't properly initialised.
from wp-browser.
Yes,
as you rightfully did the wpRootFolder
param of WPLoader
configuration needs to point to the WordPress core folder (the one containing wp-load.php
) and custom installations will need to change that.
I've got no experience with Themosis but, looking at the framework composer configuration file I'd set up the wpRootFolder
parameter to /your/local/sites/site/htdocs/cms
; then, if the framework needs that, use the configFile
parameter to load whatever bootstrap file is needed for the framework to work (see the config guide).
from wp-browser.
Cool, thanks, I'll take a look at this very shortly and hopefully will be able to get back to you with a working themosis/pods setup and details of the final config.
Cheers
from wp-browser.
Closing due to lacking activity.
from wp-browser.
Related Issues (20)
- [BUG] Git Hub Pages are Down? HOT 1
- [BUG] "Could not find a WordPress installation" error when initialising a plugin HOT 1
- [BUG] `amEditingUserWithId()` method missing from v4 HOT 1
- [BUG] Ajax tests fail HOT 2
- [BUG] Tests fail when being run from phpstorm HOT 3
- https://wpbrowser.wptestkit.dev/ not working HOT 1
- [FEATURE REQUEST] Add (grab|see)TransientInDatabase methods to WPDb
- [BUG] v4 doesn't like database names with periods in them HOT 1
- [DOC REQUEST] Test examples HOT 4
- [BUG] Can't access WP built-in functions even when using WPLoader HOT 14
- [BUG] Empty < Invalid database name: > when trying to add WPLoader HOT 2
- [BUG] v4 uses `__wakeup`, which many plugins have overridden with an error. HOT 3
- [BUG] WPLoader doesn't load wordpress installation HOT 11
- [DOC REQUEST] Setup issues HOT 4
- [BUG] Warnings while running tests HOT 1
- [SETUP ISSUE] failed activation, invalid Chrome binary HOT 4
- [FEATURE REQUEST] Integrate with ACF HOT 3
- [SETUP ISSUE] Teardown error — $wpdb is null HOT 5
- [FEATURE REQUEST] Lock WordPress to Specific Version HOT 4
- [BUG] race conditions & bugs due to connecting twice to database with WPTestCase and WPLoader | v3 HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-browser.