<?php
namespace App\Models;

class PostTest extends \PHPUnit\Framework\TestCase
{
    /**
     *
     * @test
     */
    public function databaseInteractionsSuccess()
    {
        $post = new Post();

        $this->assertTrue($post->showAll());

        $category_entry = [
            'category' => 'Akademik,Jadwal,Dosen'
        ];

        $this->assertTrue($post->entry('kategori', $category_entry));

        $category_update = [
            'category' => 'Akakademik'
        ];

        $this->assertTrue($post->update('kategori', $category_update, 1));

        $post_entry = [
            'category' => 3,
            'expired_at' => '2017-09-02',
            'creator' => 2,
            'content' => 'barbarbarbarbarbarbar!'
        ];

        $this->assertTrue($post->entry('pengumuman', $post_entry));

        $post_update = [
            'category' => 2,
            'content' => 'foofoofoofoo!'
        ];

        $this->assertTrue($post->update('pengumuman', $post_update, 1));
        
        $this->assertTrue($post->showSingle(1));

        $this->assertTrue($post->delete('pengumuman', 1));

        $this->assertTrue($post->dropTable(['pengumuman', 'kategori']));
    }
}
