* @copyright Meritoo * * @internal * @covers \Meritoo\Common\ValueObject\Human */ class HumanTest extends BaseTestCase { public function provideHuman() { yield [ 'Without any data (an empty human)', new Human('', ''), '', ]; yield [ 'With first and last name only', new Human('John', 'Scott'), 'John Scott', ]; yield [ 'With first name, last name and email', new Human('John', 'Scott', 'john@scott.com'), 'John Scott ', ]; yield [ 'With whole/complete data', new Human('John', 'Scott', 'john@scott.com', new DateTime('2001-01-01')), 'John Scott ', ]; } public function testConstructor() { static::assertConstructorVisibilityAndArguments( Human::class, OopVisibilityType::IS_PUBLIC, 4, 2 ); } public function testGetBirthDate() { $empty = new Human('', ''); static::assertNull($empty->getBirthDate()); $human = new Human('John', 'Scott', '', new DateTime('2001-01-01')); static::assertEquals(new DateTime('2001-01-01'), $human->getBirthDate()); } public function testGetEmail() { $empty = new Human('', ''); static::assertNull($empty->getEmail()); $human = new Human('John', 'Scott', 'john@scott.com'); static::assertSame('john@scott.com', $human->getEmail()); } public function testGetFirstName() { $empty = new Human('', ''); static::assertSame('', $empty->getFirstName()); $human = new Human('John', 'Scott'); static::assertSame('John', $human->getFirstName()); } public function testGetFullName() { $empty = new Human('', ''); static::assertSame('', $empty->getFullName()); $human = new Human('John', 'Scott', '', new DateTime('2001-01-01')); static::assertSame('John Scott', $human->getFullName()); } public function testGetLastName() { $empty = new Human('', ''); static::assertSame('', $empty->getLastName()); $human = new Human('John', 'Scott'); static::assertSame('Scott', $human->getLastName()); } /** * @param string $description Description of test * @param Human $human Human to verify * @param string $expected Expected string * * @dataProvider provideHuman */ public function testToString($description, Human $human, $expected) { static::assertSame($expected, (string) $human, $description); } }