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';
|
require_once '../vendor/autoload.php';
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use DJMixHosting\DJ;
|
use DJMixHosting\DJ;
|
||||||
use mysqli;
|
use PHPUnit\Framework\TestCase;
|
||||||
use mysqli_stmt;
|
|
||||||
use mysqli_result;
|
|
||||||
|
|
||||||
class DJTest extends TestCase
|
class DJTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -15,30 +12,9 @@ class DJTest extends TestCase
|
||||||
private $mockResult;
|
private $mockResult;
|
||||||
private $dj;
|
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()
|
public function testLoadFromId()
|
||||||
{
|
{
|
||||||
$djData = [
|
$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,];
|
||||||
'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
|
// Mock the prepared statement and its behavior
|
||||||
$this->mockStmt->method('bind_param')->willReturn(true);
|
$this->mockStmt->method('bind_param')->willReturn(true);
|
||||||
|
@ -67,21 +43,7 @@ class DJTest extends TestCase
|
||||||
|
|
||||||
public function testLoadFromSlug()
|
public function testLoadFromSlug()
|
||||||
{
|
{
|
||||||
$djData = [
|
$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,];
|
||||||
'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
|
// Mock the prepared statement and its behavior
|
||||||
$this->mockStmt->method('bind_param')->willReturn(true);
|
$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->assertEquals('2021-01-01 00:00:00', $this->dj->get_updated());
|
||||||
$this->assertFalse($this->dj->get_claimed());
|
$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