Modify Model become abstract, create database interactions and do test.

This commit is contained in:
2017-08-31 14:53:17 +07:00
parent 5ca179fac7
commit a075e1c36e
3 changed files with 190 additions and 17 deletions

31
_tests/unit/PostTest.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
namespace App\Models;
class PostTest extends \PHPUnit\Framework\TestCase
{
/**
*
* @test
*/
public function showDataSuccess()
{
$post = new Post();
$this->assertTrue($post->showAll());
$fields = ['category', 'expired_at', 'creator', 'content'];
$values = ['3', '2017-09-02', '2', 'barbarbarbarbarbarbar!'];
$this->assertTrue($post->entry($fields, $values));
$args = ['category' => 5, 'content' => 'foofoofoofoo!'];
$this->assertTrue($post->update($args, 1));
$this->assertTrue($post->showSingle(1));
$this->assertTrue($post->delete(1));
$this->assertTrue($post->dropTable('pengumuman'));
}
}