public function testPostTypeConstructor() { Post::registerPostType('video', 'Video'); $post = new Post(); $model = $post->newFromBuilder(['post_type' => 'video']); $this->assertInstanceOf("Video", $model); }
public function getMetaOf($post_type, $meta_key) { $post = Post::where('post_type', $post_type)->get()->first(); if (empty($post)) { return array(); } $meta = $post->meta()->get()->where('meta_key', $meta_key)->pluck('meta_value', 'meta_key')->first(); return !empty($meta) ? $meta : null; }
public function testInsertCustomFields() { $post = new Post(); $post->save(); $post->meta->username = '******'; $post->meta->url = 'http://grossi.io'; $post->save(); $post = Post::find($post->ID); $this->assertEquals($post->meta->username, 'juniorgrossi'); $this->assertEquals($post->meta->url, 'http://grossi.io'); }
public function testAuthorFields() { $post = Post::find(1); $this->assertEquals($post->author->display_name, 'admin'); $this->assertEquals($post->author->user_email, '*****@*****.**'); }
public function testPostFormat() { $post = Post::find(3); $this->assertEquals('video', $post->getFormat()); $post = Post::find(1); $this->assertFalse($post->getFormat()); }
public function testUserHasMeta() { $post = Post::published()->hasMeta('username', 'juniorgrossi')->first(); $this->assertTrue($post instanceof \Corcel\Post); }
public function testQueryPostByMeta() { $post = Post::hasMeta('username', 'juniorgrossi')->first(); $this->assertEquals(1, $post->ID); }