dingo-d / wp-pest

A package that will add WordPress integration test suite with Pest
MIT License
119 stars 5 forks source link

Database cleanup after every test #29

Open dingo-d opened 11 months ago

dingo-d commented 11 months ago

Describe your bug

In the #18 it was noted that the DB isn't being cleaned up after each tests.

The default WP integration test case should cover this already, but I'll need to investigate.

Steps to Reproduce

  1. Create the following test:
    test("Adding a record to the db", function () {
    global $wpdb;
    $row = $wpdb->get_row("
        SELECT *
        FROM {$wpdb->postmeta}
        WHERE meta_id=6969
    ", ARRAY_A);
    expect($row)->not()->toBeEmpty();
    })->with([
    function () {
        global $wpdb;
        $wpdb->insert($wpdb->postmeta, [
            'meta_id' => 6969,
            'post_id' => 9696,
            'meta_key' => 'testing',
            'meta_value' => 'Just a test.'
        ]);
    }
    ]);
  2. Run it twice
  3. See the results

Expected behavior

Test should pass every time the test suite is run.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in this repo.

Yes