Skip to content

Commit

Permalink
WIP UserTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitriBouteille committed Mar 12, 2024
1 parent b0c9b43 commit 3286952
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions tests/WordPress/Models/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace Dbout\WpOrm\Tests\WordPress\Models;

use Dbout\WpOrm\Models\User;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass \Dbout\WpOrm\Models\User
*/
class UserTest extends TestCase
class UserTest extends \WP_UnitTestCase
{
private const USER_EMAIL = '[email protected]';
private const USER_LOGIN = 'testing.wp-orm';
Expand All @@ -32,10 +31,10 @@ public static function setUpBeforeClass(): void
*/
public function testFindOneByEmailWithExistingUser(): void
{
global $wpdb;
$user = User::findOneByEmail(self::USER_EMAIL);
$this->assertInstanceOf(User::class, $user);
$this->assertEquals(self::$testingUserId, $user->getId());
$this->assertEquals(self::USER_LOGIN, $user->getUserLogin());
$this->returnUserTests($user);
var_dump($wpdb->last_query);
}

/**
Expand All @@ -47,4 +46,25 @@ public function testFindOneByEmailWithInvalidUser(): void
$user = User::findOneByEmail('[email protected]');
$this->assertNull($user);
}

/**
* @return void
* @covers ::findOneByLogin
*/
public function testFindOneByLoginWithExistingUser(): void
{
$user = User::findOneByLogin(self::USER_LOGIN);
$this->returnUserTests($user);
}

/**
* @param User|null $user
* @return void
*/
private function returnUserTests(?User $user): void
{
$this->assertInstanceOf(User::class, $user);
$this->assertEquals(self::$testingUserId, $user->getId());
$this->assertEquals(self::USER_LOGIN, $user->getUserLogin());
}
}

0 comments on commit 3286952

Please sign in to comment.