PHPUnit stuff.
This commit is contained in:
parent
74f1d6e193
commit
37e5f50804
1 changed files with 10 additions and 41 deletions
|
@ -2,11 +2,8 @@
|
|||
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use DJMixHosting\DJ;
|
||||
use mysqli;
|
||||
use mysqli_stmt;
|
||||
use mysqli_result;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DJTest extends TestCase
|
||||
{
|
||||
|
@ -15,30 +12,9 @@ class DJTest extends TestCase
|
|||
private $mockResult;
|
||||
private $dj;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->mockDb = $this->createMock(mysqli::class);
|
||||
$this->mockStmt = $this->createMock(mysqli_stmt::class);
|
||||
$this->mockResult = $this->createMock(mysqli_result::class);
|
||||
}
|
||||
|
||||
public function testLoadFromId()
|
||||
{
|
||||
$djData = [
|
||||
'id' => 1,
|
||||
'name' => 'Test DJ',
|
||||
'bio' => 'This is a test bio',
|
||||
'slug' => 'test-dj',
|
||||
'img' => '/djs/test-dj.png',
|
||||
'email' => 'test@example.com',
|
||||
'facebook_url' => 'http://facebook.com/testdj',
|
||||
'instagram_url' => 'http://instagram.com/testdj',
|
||||
'twitter_url' => 'http://twitter.com/testdj',
|
||||
'active' => 1,
|
||||
'created' => '2021-01-01 00:00:00',
|
||||
'lastupdated' => '2021-01-01 00:00:00',
|
||||
'claimed_by' => null,
|
||||
];
|
||||
$djData = ['id' => 1, 'name' => 'Test DJ', 'bio' => 'This is a test bio', 'slug' => 'test-dj', 'img' => '/djs/test-dj.png', 'email' => 'test@example.com', 'facebook_url' => 'http://facebook.com/testdj', 'instagram_url' => 'http://instagram.com/testdj', 'twitter_url' => 'http://twitter.com/testdj', 'active' => 1, 'created' => '2021-01-01 00:00:00', 'lastupdated' => '2021-01-01 00:00:00', 'claimed_by' => null,];
|
||||
|
||||
// Mock the prepared statement and its behavior
|
||||
$this->mockStmt->method('bind_param')->willReturn(true);
|
||||
|
@ -67,21 +43,7 @@ class DJTest extends TestCase
|
|||
|
||||
public function testLoadFromSlug()
|
||||
{
|
||||
$djData = [
|
||||
'id' => 1,
|
||||
'name' => 'Test DJ',
|
||||
'bio' => 'This is a test bio',
|
||||
'slug' => 'test-dj',
|
||||
'img' => '/djs/test-dj.png',
|
||||
'email' => 'test@example.com',
|
||||
'facebook_url' => 'http://facebook.com/testdj',
|
||||
'instagram_url' => 'http://instagram.com/testdj',
|
||||
'twitter_url' => 'http://twitter.com/testdj',
|
||||
'active' => 1,
|
||||
'created' => '2021-01-01 00:00:00',
|
||||
'lastupdated' => '2021-01-01 00:00:00',
|
||||
'claimed_by' => null,
|
||||
];
|
||||
$djData = ['id' => 1, 'name' => 'Test DJ', 'bio' => 'This is a test bio', 'slug' => 'test-dj', 'img' => '/djs/test-dj.png', 'email' => 'test@example.com', 'facebook_url' => 'http://facebook.com/testdj', 'instagram_url' => 'http://instagram.com/testdj', 'twitter_url' => 'http://twitter.com/testdj', 'active' => 1, 'created' => '2021-01-01 00:00:00', 'lastupdated' => '2021-01-01 00:00:00', 'claimed_by' => null,];
|
||||
|
||||
// Mock the prepared statement and its behavior
|
||||
$this->mockStmt->method('bind_param')->willReturn(true);
|
||||
|
@ -107,4 +69,11 @@ class DJTest extends TestCase
|
|||
$this->assertEquals('2021-01-01 00:00:00', $this->dj->get_updated());
|
||||
$this->assertFalse($this->dj->get_claimed());
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->mockDb = $this->createMock(mysqli::class);
|
||||
$this->mockStmt = $this->createMock(mysqli_stmt::class);
|
||||
$this->mockResult = $this->createMock(mysqli_result::class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue