60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Domain\User;
|
|
|
|
use App\Domain\User\User;
|
|
use Tests\TestCase;
|
|
|
|
class UserTest extends TestCase
|
|
{
|
|
public function userProvider()
|
|
{
|
|
return [
|
|
[1, 'bill.gates', 'Bill', 'Gates'],
|
|
[2, 'steve.jobs', 'Steve', 'Jobs'],
|
|
[3, 'mark.zuckerberg', 'Mark', 'Zuckerberg'],
|
|
[4, 'evan.spiegel', 'Evan', 'Spiegel'],
|
|
[5, 'jack.dorsey', 'Jack', 'Dorsey'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider userProvider
|
|
* @param int $id
|
|
* @param string $username
|
|
* @param string $firstName
|
|
* @param string $lastName
|
|
*/
|
|
public function testGetters(int $id, string $username, string $firstName, string $lastName)
|
|
{
|
|
$user = new User($id, $username, $firstName, $lastName);
|
|
|
|
$this->assertEquals($id, $user->getId());
|
|
$this->assertEquals($username, $user->getUsername());
|
|
$this->assertEquals($firstName, $user->getFirstName());
|
|
$this->assertEquals($lastName, $user->getLastName());
|
|
}
|
|
|
|
/**
|
|
* @dataProvider userProvider
|
|
* @param int $id
|
|
* @param string $username
|
|
* @param string $firstName
|
|
* @param string $lastName
|
|
*/
|
|
public function testJsonSerialize(int $id, string $username, string $firstName, string $lastName)
|
|
{
|
|
$user = new User($id, $username, $firstName, $lastName);
|
|
|
|
$expectedPayload = json_encode([
|
|
'id' => $id,
|
|
'username' => $username,
|
|
'firstName' => $firstName,
|
|
'lastName' => $lastName,
|
|
]);
|
|
|
|
$this->assertEquals($expectedPayload, json_encode($user));
|
|
}
|
|
}
|