diff --git a/README.markdown b/README.markdown index f2b51b0..e6b6c24 100644 --- a/README.markdown +++ b/README.markdown @@ -39,6 +39,8 @@ create a new Issue. ## Example Fixture +### JSON +
 {
 	"posts": [
@@ -55,7 +57,8 @@ create a new Issue.
 						"lots", "of", "nested", "datatypes"
 					]
 				}
-			}
+			},
+			"tags": "tag 1,tag2"
 		},
 		{
 			"post_date": "2010-01-01 10:00am",
@@ -73,3 +76,6 @@ create a new Issue.
 	}
 }
 
+ +### PHP + diff --git a/classes/FixtureBuilder.inc b/classes/FixtureBuilder.inc index 481e907..1bb219a 100644 --- a/classes/FixtureBuilder.inc +++ b/classes/FixtureBuilder.inc @@ -59,6 +59,13 @@ class FixtureBuilder { return $this; } + function content($content) { + $this->check_correct_type('post'); + + $this->current_object['post']['post_content'] = $content; + return $this; + } + function tags($tags) { $this->check_correct_type('post'); @@ -95,6 +102,11 @@ class FixtureBuilder { return $this; } + function option($name, $value) { + update_option($name, $value); + return $this; + } + function defer_category($obj) { $this->deferred_builds['category'] = array_merge($this->deferred_builds['category'], explode(',', $obj['name'])); } diff --git a/classes/PostFixtures.inc b/classes/PostFixtures.inc index 96f858e..0513189 100644 --- a/classes/PostFixtures.inc +++ b/classes/PostFixtures.inc @@ -69,6 +69,9 @@ class PostFixtures { $builder = new FixtureBuilder(); include($file); $builder->finalize(); + + $this->messages[] = __("New data set loaded into WordPress.", 'post-fixtures'); + break; } } diff --git a/test/FixtureBuilderTest.php b/test/FixtureBuilderTest.php index 08e69bd..e2287dc 100644 --- a/test/FixtureBuilderTest.php +++ b/test/FixtureBuilderTest.php @@ -126,6 +126,10 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase { 'date', array('2010-01-01') ), + array( + 'content', + array('Post content') + ), array( 'categories', array('test') @@ -141,6 +145,7 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase { ), (object)array( 'post_title' => 'Post title', + 'post_content' => 'Post content', 'post_type' => 'post', 'post_date' => '2010-01-01', 'post_status' => 'publish', @@ -150,6 +155,7 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase { 'posts' => array( 1 => (object)array( 'post_title' => 'Post title', + 'post_content' => 'Post content', 'post_type' => 'post', 'post_date' => '2010-01-01', 'post_status' => 'publish', @@ -168,7 +174,7 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase { ) ) ) - ) + ), ); } @@ -228,4 +234,11 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase { $fb->finalize(); } + + function testOption() { + $fb = new FixtureBuilder(); + $fb->option('test', 'value'); + + $this->assertEquals('value', get_option('test')); + } }