Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created June 7, 2010 00:49
Show Gist options
  • Save michaeltwofish/428076 to your computer and use it in GitHub Desktop.
Save michaeltwofish/428076 to your computer and use it in GitHub Desktop.
public function test_create_post()
{
$tags = array('one', 'two', 'THREE');
$params = array(
'title' => $this->get_title(),
'content' => $this->get_content(1, 3, 'some', array('ol'=>1, 'ul'=>1), 'cat'),
'user_id' => $this->user->id,
'status' => Post::status('published'),
'content_type' => Post::type('entry'),
'tags' => 'one, two, THREE',
'pubdate' => HabariDateTime::date_create( time() ),
);
$post = Post::create($params);
$this->assertType('Post', $post, 'Post should be created.');
// Check the post's id is set.
$this->assertGreaterThan(0, (int)$post->id, 'The Post id should be greater than zero');
// Check the post's tags are usable.
$this->assertEquals(count($post->tags), count($tags), 'All tags should have been created.');
foreach ( $post->tags as $tag_slug => $tag_text ) {
$this->assertEquals($tag_slug, Utils::slugify($tag_text), 'Tags key should be slugified tag.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment