Plugin Directory

Post Fixtures

Post Fixtures let you quickly tear down and set up test environments within your development WordPress environment.

What are the data formats accepted?

JSON

{
    "posts": [
        {
            "post_date": "2010-01-01 9:00am",
            "post_title": "This is a sample post",
            "post_content": "This is the post's content",
            "categories": [ "Top Level 1/Sub Category 1", "Top Level 2/Sub Category 2" ],
            "metadata": {
                "field-1": "value 1",
                "field-2": {
                    "a_complex": "field",
                    "with": [
                        "lots", "of", "nested", "datatypes"
                    ]
                }
            },
            "tags": "tag 1,tag 2"
        },
        {
            "post_date": "2010-01-01 10:00am",
            "post_title": "This is the second sample post",
            "post_content": "This is the second post's content",
            "categories": [ "Top Level 1/Sub Category 2", "Top Level 2/Sub Category 2" ]
        }
    ],
    "options": {
        "an-option-to-set": "simple-string",
        "an-option-to-serialize": {
            "this": "is a hash"
        },
        "an-option-to-delete": false
    }
}

PHP

// build an object immediately, and get the new post's ID
$post_id = $builder->post('This is a sample post')
                   ->date('2010-01-01 9:00am')
                   ->content("This is the post's content")
                   ->categories("Top Level 1/Sub Category 1,Top Level 2/Sub Category 2")
                   ->metadata('field-1', 'value-1')
                   ->metadata('field-2', array(
                       'a_complex' => 'field',
                       'with' => array(
                        'lots', 'of', 'nested', 'datatypes'
                       )
                     ))
                   ->tags('tag 1,tag 2')->build();

// build and object at the end, if order doesn't matter
$builder->post('This is the second sample post')
        ->date('2010-01-01 10:00am')
        ->content("This is the second post's content")
        ->categories("Top Level 1/Sub Category 2,Top Level 2/Sub Category 2")->defer();

// convenience wrapper around options setting
$builder->option('an-option-to-set', 'simple-string')
        ->option('an-option-to-serialize', array('this' => 'is a hash'))
        ->option('an-option-to-delete', false);

Requires: 2.8 or higher
Compatible up to: 2.9.2
Last Updated: 2010-2-14
Downloads: 209

Average Rating

0 stars
(0 ratings)

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.