Modify Model become abstract, create database interactions and do test.
This commit is contained in:
31
_tests/unit/PostTest.php
Normal file
31
_tests/unit/PostTest.php
Normal 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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user