How can I test for WP_Error?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm writing tests using phpunit and WP_Mock for a WordPress plugin and I want to return a WP_Error if the method in my class isn't being called correctly (receiving all of the arguments it needs).



The standard way of doing this of course, would be to create and return a new WP_Error at that point - but as WordPress isn't loaded when I run the tests, the WP_Error class doesn't exist.



Other WordPress classes are being mocked and injected with Mockery, but this seems like overkill to test the WP_Error is being thrown; but I'm not seeing any other half-way sensible plan.



Is there a good way to mock the WP_Error?










share|improve this question

























  • “but as Wordpress isn't yet loaded, that class doesn't exist” - well then what do you actually want to test at this point …?

    – misorude
    Nov 16 '18 at 12:38











  • The code I'm writing to extend it; everything else I'm mocking and injecting as a dependency, and that's an option I'm considering, but it feels like there ought to be a better solution.

    – piersb
    Nov 16 '18 at 13:38











  • I would start by using the template_redirect action hook , "This action hook executes just before WordPress determines which template page to load" .

    – Jamie_D
    Nov 16 '18 at 14:00


















0















I'm writing tests using phpunit and WP_Mock for a WordPress plugin and I want to return a WP_Error if the method in my class isn't being called correctly (receiving all of the arguments it needs).



The standard way of doing this of course, would be to create and return a new WP_Error at that point - but as WordPress isn't loaded when I run the tests, the WP_Error class doesn't exist.



Other WordPress classes are being mocked and injected with Mockery, but this seems like overkill to test the WP_Error is being thrown; but I'm not seeing any other half-way sensible plan.



Is there a good way to mock the WP_Error?










share|improve this question

























  • “but as Wordpress isn't yet loaded, that class doesn't exist” - well then what do you actually want to test at this point …?

    – misorude
    Nov 16 '18 at 12:38











  • The code I'm writing to extend it; everything else I'm mocking and injecting as a dependency, and that's an option I'm considering, but it feels like there ought to be a better solution.

    – piersb
    Nov 16 '18 at 13:38











  • I would start by using the template_redirect action hook , "This action hook executes just before WordPress determines which template page to load" .

    – Jamie_D
    Nov 16 '18 at 14:00














0












0








0








I'm writing tests using phpunit and WP_Mock for a WordPress plugin and I want to return a WP_Error if the method in my class isn't being called correctly (receiving all of the arguments it needs).



The standard way of doing this of course, would be to create and return a new WP_Error at that point - but as WordPress isn't loaded when I run the tests, the WP_Error class doesn't exist.



Other WordPress classes are being mocked and injected with Mockery, but this seems like overkill to test the WP_Error is being thrown; but I'm not seeing any other half-way sensible plan.



Is there a good way to mock the WP_Error?










share|improve this question
















I'm writing tests using phpunit and WP_Mock for a WordPress plugin and I want to return a WP_Error if the method in my class isn't being called correctly (receiving all of the arguments it needs).



The standard way of doing this of course, would be to create and return a new WP_Error at that point - but as WordPress isn't loaded when I run the tests, the WP_Error class doesn't exist.



Other WordPress classes are being mocked and injected with Mockery, but this seems like overkill to test the WP_Error is being thrown; but I'm not seeing any other half-way sensible plan.



Is there a good way to mock the WP_Error?







php wordpress unit-testing phpunit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 18:00









yivi

5,86372855




5,86372855










asked Nov 16 '18 at 12:14









piersbpiersb

434519




434519













  • “but as Wordpress isn't yet loaded, that class doesn't exist” - well then what do you actually want to test at this point …?

    – misorude
    Nov 16 '18 at 12:38











  • The code I'm writing to extend it; everything else I'm mocking and injecting as a dependency, and that's an option I'm considering, but it feels like there ought to be a better solution.

    – piersb
    Nov 16 '18 at 13:38











  • I would start by using the template_redirect action hook , "This action hook executes just before WordPress determines which template page to load" .

    – Jamie_D
    Nov 16 '18 at 14:00



















  • “but as Wordpress isn't yet loaded, that class doesn't exist” - well then what do you actually want to test at this point …?

    – misorude
    Nov 16 '18 at 12:38











  • The code I'm writing to extend it; everything else I'm mocking and injecting as a dependency, and that's an option I'm considering, but it feels like there ought to be a better solution.

    – piersb
    Nov 16 '18 at 13:38











  • I would start by using the template_redirect action hook , "This action hook executes just before WordPress determines which template page to load" .

    – Jamie_D
    Nov 16 '18 at 14:00

















“but as Wordpress isn't yet loaded, that class doesn't exist” - well then what do you actually want to test at this point …?

– misorude
Nov 16 '18 at 12:38





“but as Wordpress isn't yet loaded, that class doesn't exist” - well then what do you actually want to test at this point …?

– misorude
Nov 16 '18 at 12:38













The code I'm writing to extend it; everything else I'm mocking and injecting as a dependency, and that's an option I'm considering, but it feels like there ought to be a better solution.

– piersb
Nov 16 '18 at 13:38





The code I'm writing to extend it; everything else I'm mocking and injecting as a dependency, and that's an option I'm considering, but it feels like there ought to be a better solution.

– piersb
Nov 16 '18 at 13:38













I would start by using the template_redirect action hook , "This action hook executes just before WordPress determines which template page to load" .

– Jamie_D
Nov 16 '18 at 14:00





I would start by using the template_redirect action hook , "This action hook executes just before WordPress determines which template page to load" .

– Jamie_D
Nov 16 '18 at 14:00












3 Answers
3






active

oldest

votes


















1





+50









Easiest way:
Just include_once the file with the definition for WP_Error (wp-includes/class-wp-error.php) when bootstrapping your tests. That way the class will be defined when you need to instantiate the class.



WP_Error doesn't have any other dependencies, so including it should be a big deal.



You are not not testing actual behaviour of the class, but only an object of that class is returned. So no need to mock anything if the proper definition exists.



Better way:
Use WP-CLI to scaffold. Doing that you'd have access to wordpress functions and classes.



You'll need to install WP-CLI and have a working WP installation, with your plugin files in there.



First you'd need to do the plugin scaffolding. In your WP directory run



wp scaffold plugin-tests your-plugin


This will create a set of files in your plugin directory similar to this:



|-bin/
|----install-wp-tests.sh
|-tests/
|----bootstrap.php
|----test-sample.php
|-.travis.yml
|-phpcs.xml.dist
|-phpunit.xml.dist
|-your-plugin.php


You'll need to cd to your plugin directory, and from there run the test environment initialization:



bin/install-wp-tests.sh db_name db_user 'db_password' db_host wp_version


Parameters are self explanatory. wp_version can be latest. On this DB wp-cli will create a set of tables for testing, and it will create a WP installation in your /tmp directory, configured with the above values that will use in each time you run phpunit.



After that, it's a simple matter of calling phpunit and run your tests. You can use the test-sample.phpas a starting point, or copy yours over there.



When running your tests this way, WP_Error will be defined, and you could easily test that your methods are returning it correctly.



Happy testing!






share|improve this answer


























  • I can't use WP-CLI, as I'm using WP_Mock, and the two testing frameworks are mutually incompatible. However, include-oncing seems to be the least bad solution available. So the bounty is yours!

    – piersb
    Nov 26 '18 at 11:41













  • WP-CLI is not a testing framework. But it is too bad WP_Mock is not compatible.

    – yivi
    Nov 26 '18 at 11:41













  • I mean the Wordpress testing framework which is installed via WP-CLI scaffold, per your answer.

    – piersb
    Nov 26 '18 at 11:43













  • Yeah, understand. I'll have to read more about WP_Mock. But just including the file should get you out of this, since you do not need to actually mock WP_Error.

    – yivi
    Nov 26 '18 at 11:44



















2














Method 1:



Execute your tests after plugins_loaded action, like:



add_action('plugins_loaded', 'your_func');
function your_func()
{
...
}


Method 2:



Include once the WP_error class :



include_once(ABSPATH.'wp-includes/class-wp-error.php');
...
your code





share|improve this answer































    0














    Learning from T.Todua's answer, my composer.json looks like:



    {
    "require-dev": {
    "10up/wp_mock": "0.4.2",
    "johnpbloch/wordpress": "5.*"
    },
    "extra": {
    "wordpress-install-dir": "vendor/wordpress"
    }
    }


    and in my tests/UnitTest.php setUp() method, I have:



    $basedir = dirname( dirname( __FILE__ ) );

    require_once( $basedir . '/vendor/wordpress/wp-includes/class-wp-error.php' );





    share|improve this answer
























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337710%2fhow-can-i-test-for-wp-error%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1





      +50









      Easiest way:
      Just include_once the file with the definition for WP_Error (wp-includes/class-wp-error.php) when bootstrapping your tests. That way the class will be defined when you need to instantiate the class.



      WP_Error doesn't have any other dependencies, so including it should be a big deal.



      You are not not testing actual behaviour of the class, but only an object of that class is returned. So no need to mock anything if the proper definition exists.



      Better way:
      Use WP-CLI to scaffold. Doing that you'd have access to wordpress functions and classes.



      You'll need to install WP-CLI and have a working WP installation, with your plugin files in there.



      First you'd need to do the plugin scaffolding. In your WP directory run



      wp scaffold plugin-tests your-plugin


      This will create a set of files in your plugin directory similar to this:



      |-bin/
      |----install-wp-tests.sh
      |-tests/
      |----bootstrap.php
      |----test-sample.php
      |-.travis.yml
      |-phpcs.xml.dist
      |-phpunit.xml.dist
      |-your-plugin.php


      You'll need to cd to your plugin directory, and from there run the test environment initialization:



      bin/install-wp-tests.sh db_name db_user 'db_password' db_host wp_version


      Parameters are self explanatory. wp_version can be latest. On this DB wp-cli will create a set of tables for testing, and it will create a WP installation in your /tmp directory, configured with the above values that will use in each time you run phpunit.



      After that, it's a simple matter of calling phpunit and run your tests. You can use the test-sample.phpas a starting point, or copy yours over there.



      When running your tests this way, WP_Error will be defined, and you could easily test that your methods are returning it correctly.



      Happy testing!






      share|improve this answer


























      • I can't use WP-CLI, as I'm using WP_Mock, and the two testing frameworks are mutually incompatible. However, include-oncing seems to be the least bad solution available. So the bounty is yours!

        – piersb
        Nov 26 '18 at 11:41













      • WP-CLI is not a testing framework. But it is too bad WP_Mock is not compatible.

        – yivi
        Nov 26 '18 at 11:41













      • I mean the Wordpress testing framework which is installed via WP-CLI scaffold, per your answer.

        – piersb
        Nov 26 '18 at 11:43













      • Yeah, understand. I'll have to read more about WP_Mock. But just including the file should get you out of this, since you do not need to actually mock WP_Error.

        – yivi
        Nov 26 '18 at 11:44
















      1





      +50









      Easiest way:
      Just include_once the file with the definition for WP_Error (wp-includes/class-wp-error.php) when bootstrapping your tests. That way the class will be defined when you need to instantiate the class.



      WP_Error doesn't have any other dependencies, so including it should be a big deal.



      You are not not testing actual behaviour of the class, but only an object of that class is returned. So no need to mock anything if the proper definition exists.



      Better way:
      Use WP-CLI to scaffold. Doing that you'd have access to wordpress functions and classes.



      You'll need to install WP-CLI and have a working WP installation, with your plugin files in there.



      First you'd need to do the plugin scaffolding. In your WP directory run



      wp scaffold plugin-tests your-plugin


      This will create a set of files in your plugin directory similar to this:



      |-bin/
      |----install-wp-tests.sh
      |-tests/
      |----bootstrap.php
      |----test-sample.php
      |-.travis.yml
      |-phpcs.xml.dist
      |-phpunit.xml.dist
      |-your-plugin.php


      You'll need to cd to your plugin directory, and from there run the test environment initialization:



      bin/install-wp-tests.sh db_name db_user 'db_password' db_host wp_version


      Parameters are self explanatory. wp_version can be latest. On this DB wp-cli will create a set of tables for testing, and it will create a WP installation in your /tmp directory, configured with the above values that will use in each time you run phpunit.



      After that, it's a simple matter of calling phpunit and run your tests. You can use the test-sample.phpas a starting point, or copy yours over there.



      When running your tests this way, WP_Error will be defined, and you could easily test that your methods are returning it correctly.



      Happy testing!






      share|improve this answer


























      • I can't use WP-CLI, as I'm using WP_Mock, and the two testing frameworks are mutually incompatible. However, include-oncing seems to be the least bad solution available. So the bounty is yours!

        – piersb
        Nov 26 '18 at 11:41













      • WP-CLI is not a testing framework. But it is too bad WP_Mock is not compatible.

        – yivi
        Nov 26 '18 at 11:41













      • I mean the Wordpress testing framework which is installed via WP-CLI scaffold, per your answer.

        – piersb
        Nov 26 '18 at 11:43













      • Yeah, understand. I'll have to read more about WP_Mock. But just including the file should get you out of this, since you do not need to actually mock WP_Error.

        – yivi
        Nov 26 '18 at 11:44














      1





      +50







      1





      +50



      1




      +50





      Easiest way:
      Just include_once the file with the definition for WP_Error (wp-includes/class-wp-error.php) when bootstrapping your tests. That way the class will be defined when you need to instantiate the class.



      WP_Error doesn't have any other dependencies, so including it should be a big deal.



      You are not not testing actual behaviour of the class, but only an object of that class is returned. So no need to mock anything if the proper definition exists.



      Better way:
      Use WP-CLI to scaffold. Doing that you'd have access to wordpress functions and classes.



      You'll need to install WP-CLI and have a working WP installation, with your plugin files in there.



      First you'd need to do the plugin scaffolding. In your WP directory run



      wp scaffold plugin-tests your-plugin


      This will create a set of files in your plugin directory similar to this:



      |-bin/
      |----install-wp-tests.sh
      |-tests/
      |----bootstrap.php
      |----test-sample.php
      |-.travis.yml
      |-phpcs.xml.dist
      |-phpunit.xml.dist
      |-your-plugin.php


      You'll need to cd to your plugin directory, and from there run the test environment initialization:



      bin/install-wp-tests.sh db_name db_user 'db_password' db_host wp_version


      Parameters are self explanatory. wp_version can be latest. On this DB wp-cli will create a set of tables for testing, and it will create a WP installation in your /tmp directory, configured with the above values that will use in each time you run phpunit.



      After that, it's a simple matter of calling phpunit and run your tests. You can use the test-sample.phpas a starting point, or copy yours over there.



      When running your tests this way, WP_Error will be defined, and you could easily test that your methods are returning it correctly.



      Happy testing!






      share|improve this answer















      Easiest way:
      Just include_once the file with the definition for WP_Error (wp-includes/class-wp-error.php) when bootstrapping your tests. That way the class will be defined when you need to instantiate the class.



      WP_Error doesn't have any other dependencies, so including it should be a big deal.



      You are not not testing actual behaviour of the class, but only an object of that class is returned. So no need to mock anything if the proper definition exists.



      Better way:
      Use WP-CLI to scaffold. Doing that you'd have access to wordpress functions and classes.



      You'll need to install WP-CLI and have a working WP installation, with your plugin files in there.



      First you'd need to do the plugin scaffolding. In your WP directory run



      wp scaffold plugin-tests your-plugin


      This will create a set of files in your plugin directory similar to this:



      |-bin/
      |----install-wp-tests.sh
      |-tests/
      |----bootstrap.php
      |----test-sample.php
      |-.travis.yml
      |-phpcs.xml.dist
      |-phpunit.xml.dist
      |-your-plugin.php


      You'll need to cd to your plugin directory, and from there run the test environment initialization:



      bin/install-wp-tests.sh db_name db_user 'db_password' db_host wp_version


      Parameters are self explanatory. wp_version can be latest. On this DB wp-cli will create a set of tables for testing, and it will create a WP installation in your /tmp directory, configured with the above values that will use in each time you run phpunit.



      After that, it's a simple matter of calling phpunit and run your tests. You can use the test-sample.phpas a starting point, or copy yours over there.



      When running your tests this way, WP_Error will be defined, and you could easily test that your methods are returning it correctly.



      Happy testing!







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 26 '18 at 5:47

























      answered Nov 22 '18 at 17:09









      yiviyivi

      5,86372855




      5,86372855













      • I can't use WP-CLI, as I'm using WP_Mock, and the two testing frameworks are mutually incompatible. However, include-oncing seems to be the least bad solution available. So the bounty is yours!

        – piersb
        Nov 26 '18 at 11:41













      • WP-CLI is not a testing framework. But it is too bad WP_Mock is not compatible.

        – yivi
        Nov 26 '18 at 11:41













      • I mean the Wordpress testing framework which is installed via WP-CLI scaffold, per your answer.

        – piersb
        Nov 26 '18 at 11:43













      • Yeah, understand. I'll have to read more about WP_Mock. But just including the file should get you out of this, since you do not need to actually mock WP_Error.

        – yivi
        Nov 26 '18 at 11:44



















      • I can't use WP-CLI, as I'm using WP_Mock, and the two testing frameworks are mutually incompatible. However, include-oncing seems to be the least bad solution available. So the bounty is yours!

        – piersb
        Nov 26 '18 at 11:41













      • WP-CLI is not a testing framework. But it is too bad WP_Mock is not compatible.

        – yivi
        Nov 26 '18 at 11:41













      • I mean the Wordpress testing framework which is installed via WP-CLI scaffold, per your answer.

        – piersb
        Nov 26 '18 at 11:43













      • Yeah, understand. I'll have to read more about WP_Mock. But just including the file should get you out of this, since you do not need to actually mock WP_Error.

        – yivi
        Nov 26 '18 at 11:44

















      I can't use WP-CLI, as I'm using WP_Mock, and the two testing frameworks are mutually incompatible. However, include-oncing seems to be the least bad solution available. So the bounty is yours!

      – piersb
      Nov 26 '18 at 11:41







      I can't use WP-CLI, as I'm using WP_Mock, and the two testing frameworks are mutually incompatible. However, include-oncing seems to be the least bad solution available. So the bounty is yours!

      – piersb
      Nov 26 '18 at 11:41















      WP-CLI is not a testing framework. But it is too bad WP_Mock is not compatible.

      – yivi
      Nov 26 '18 at 11:41







      WP-CLI is not a testing framework. But it is too bad WP_Mock is not compatible.

      – yivi
      Nov 26 '18 at 11:41















      I mean the Wordpress testing framework which is installed via WP-CLI scaffold, per your answer.

      – piersb
      Nov 26 '18 at 11:43







      I mean the Wordpress testing framework which is installed via WP-CLI scaffold, per your answer.

      – piersb
      Nov 26 '18 at 11:43















      Yeah, understand. I'll have to read more about WP_Mock. But just including the file should get you out of this, since you do not need to actually mock WP_Error.

      – yivi
      Nov 26 '18 at 11:44





      Yeah, understand. I'll have to read more about WP_Mock. But just including the file should get you out of this, since you do not need to actually mock WP_Error.

      – yivi
      Nov 26 '18 at 11:44













      2














      Method 1:



      Execute your tests after plugins_loaded action, like:



      add_action('plugins_loaded', 'your_func');
      function your_func()
      {
      ...
      }


      Method 2:



      Include once the WP_error class :



      include_once(ABSPATH.'wp-includes/class-wp-error.php');
      ...
      your code





      share|improve this answer




























        2














        Method 1:



        Execute your tests after plugins_loaded action, like:



        add_action('plugins_loaded', 'your_func');
        function your_func()
        {
        ...
        }


        Method 2:



        Include once the WP_error class :



        include_once(ABSPATH.'wp-includes/class-wp-error.php');
        ...
        your code





        share|improve this answer


























          2












          2








          2







          Method 1:



          Execute your tests after plugins_loaded action, like:



          add_action('plugins_loaded', 'your_func');
          function your_func()
          {
          ...
          }


          Method 2:



          Include once the WP_error class :



          include_once(ABSPATH.'wp-includes/class-wp-error.php');
          ...
          your code





          share|improve this answer













          Method 1:



          Execute your tests after plugins_loaded action, like:



          add_action('plugins_loaded', 'your_func');
          function your_func()
          {
          ...
          }


          Method 2:



          Include once the WP_error class :



          include_once(ABSPATH.'wp-includes/class-wp-error.php');
          ...
          your code






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 12:28









          T.ToduaT.Todua

          32.1k12136141




          32.1k12136141























              0














              Learning from T.Todua's answer, my composer.json looks like:



              {
              "require-dev": {
              "10up/wp_mock": "0.4.2",
              "johnpbloch/wordpress": "5.*"
              },
              "extra": {
              "wordpress-install-dir": "vendor/wordpress"
              }
              }


              and in my tests/UnitTest.php setUp() method, I have:



              $basedir = dirname( dirname( __FILE__ ) );

              require_once( $basedir . '/vendor/wordpress/wp-includes/class-wp-error.php' );





              share|improve this answer




























                0














                Learning from T.Todua's answer, my composer.json looks like:



                {
                "require-dev": {
                "10up/wp_mock": "0.4.2",
                "johnpbloch/wordpress": "5.*"
                },
                "extra": {
                "wordpress-install-dir": "vendor/wordpress"
                }
                }


                and in my tests/UnitTest.php setUp() method, I have:



                $basedir = dirname( dirname( __FILE__ ) );

                require_once( $basedir . '/vendor/wordpress/wp-includes/class-wp-error.php' );





                share|improve this answer


























                  0












                  0








                  0







                  Learning from T.Todua's answer, my composer.json looks like:



                  {
                  "require-dev": {
                  "10up/wp_mock": "0.4.2",
                  "johnpbloch/wordpress": "5.*"
                  },
                  "extra": {
                  "wordpress-install-dir": "vendor/wordpress"
                  }
                  }


                  and in my tests/UnitTest.php setUp() method, I have:



                  $basedir = dirname( dirname( __FILE__ ) );

                  require_once( $basedir . '/vendor/wordpress/wp-includes/class-wp-error.php' );





                  share|improve this answer













                  Learning from T.Todua's answer, my composer.json looks like:



                  {
                  "require-dev": {
                  "10up/wp_mock": "0.4.2",
                  "johnpbloch/wordpress": "5.*"
                  },
                  "extra": {
                  "wordpress-install-dir": "vendor/wordpress"
                  }
                  }


                  and in my tests/UnitTest.php setUp() method, I have:



                  $basedir = dirname( dirname( __FILE__ ) );

                  require_once( $basedir . '/vendor/wordpress/wp-includes/class-wp-error.php' );






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 10 at 2:16









                  BrianHenryIEBrianHenryIE

                  33737




                  33737






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337710%2fhow-can-i-test-for-wp-error%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to change which sound is reproduced for terminal bell?

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?