Code Monkey home page Code Monkey logo

Comments (8)

lucatume avatar lucatume commented on June 3, 2024 1

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.

lucatume avatar lucatume commented on June 3, 2024

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.

lougreenwood avatar lougreenwood commented on June 3, 2024

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.

lougreenwood avatar lougreenwood commented on June 3, 2024

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.

lougreenwood avatar lougreenwood commented on June 3, 2024

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.

lucatume avatar lucatume commented on June 3, 2024

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.

lougreenwood avatar lougreenwood commented on June 3, 2024

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.

lucatume avatar lucatume commented on June 3, 2024

Closing due to lacking activity.

from wp-browser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.