Inheritance: extends Illuminate\Database\Eloquent\Model
示例#1
0
 public function testPostTypeConstructor()
 {
     Post::registerPostType('video', 'Video');
     $post = new Post();
     $model = $post->newFromBuilder(['post_type' => 'video']);
     $this->assertInstanceOf("Video", $model);
 }
示例#2
0
 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;
 }
示例#3
0
 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');
 }
示例#4
0
 public function testAuthorFields()
 {
     $post = Post::find(1);
     $this->assertEquals($post->author->display_name, 'admin');
     $this->assertEquals($post->author->user_email, '*****@*****.**');
 }
示例#5
0
 public function testPostFormat()
 {
     $post = Post::find(3);
     $this->assertEquals('video', $post->getFormat());
     $post = Post::find(1);
     $this->assertFalse($post->getFormat());
 }
示例#6
0
 public function testUserHasMeta()
 {
     $post = Post::published()->hasMeta('username', 'juniorgrossi')->first();
     $this->assertTrue($post instanceof \Corcel\Post);
 }
示例#7
0
 public function testQueryPostByMeta()
 {
     $post = Post::hasMeta('username', 'juniorgrossi')->first();
     $this->assertEquals(1, $post->ID);
 }