• I’m writing tests for my plugin, and I’ve put the details in the WPSE topic: https://wordpress.stackexchange.com/questions/342913/coverage-in-integration-tests

    The problem I have is that I wrote the test that will check if the custom post types are registered, and if they are the test will pass

    public function test_custom_post_types_are_registered() {
      $post_types = get_post_types();
    
      $documentation = \My_Plugin\Custom_Post_Type\Documentation::POST_TYPE_SLUG;
      $email         = \My_Plugin\Custom_Post_Type\Email_Templates::POST_TYPE_SLUG;
      $faq           = \My_Plugin\Custom_Post_Type\Faq::POST_TYPE_SLUG;
    
      $this->assertTrue( isset( $post_types[ $documentation ] ) );
      $this->assertTrue( isset( $post_types[ $email ] ) );
      $this->assertTrue( isset( $post_types[ $faq ] ) );
    }
    

    I even put the print_r in the code that is run which registers the CPT, and during the test run it’s actually shown.

    But when I generate code coverage, this code isn’t covered.

    Any guesses why?

    The page I need help with: [log in to see the link]

  • The topic ‘Integration tests are not covering code in PHPUnit’ is closed to new replies.