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