Skip to content

Commit 9fe0188

Browse files
committed
add equal check
1 parent 2901b2a commit 9fe0188

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/ValueObject/Account.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private static function convertFromNative(iterable $data): iterable
8787

8888
break;
8989
case 'firstName': // camelCase
90-
case 'first_name': // snakeCase
90+
case 'first_name': // snake_case
9191
yield 'firstName' => FirstName::fromNative($value);
9292

9393
break;

tests/ValueObject/AccountTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,30 @@ public function it_can_init_not_set_properties(): void
205205

206206
$this->assertSame(true, $account->active->v);
207207
}
208+
209+
/**
210+
* @test
211+
*/
212+
public function it_can_be_compared(): void
213+
{
214+
$account = Account::fromNative([
215+
'firstName' => FirstName::fromNative('Jane'),
216+
'lastName' => 'Doe',
217+
'address' => [
218+
'street' => 'Awesome Avenue',
219+
],
220+
'active' => false,
221+
]);
222+
$account2 = Account::fromNative([
223+
'firstName' => FirstName::fromNative('Jane'),
224+
'lastName' => 'Doe',
225+
'address' => [
226+
'street' => 'Awesome Avenue',
227+
],
228+
'active' => false,
229+
]);
230+
231+
$this->assertTrue($account->equals($account2));
232+
$this->assertFalse($account->equals($account2->with(['active' => true])));
233+
}
208234
}

tests/ValueObject/LastLoginTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,17 @@ public function it_can_be_created_from_native($value): void
3737
$this->assertSame('2022-08-20T14:37:30+00:00', $cut->toNative());
3838
$this->assertInstanceOf(\DateTimeImmutable::class, $cut->v);
3939
}
40+
41+
/**
42+
* @test
43+
*/
44+
public function it_can_be_compared(): void
45+
{
46+
$cut = LastLogin::fromNative('2022-08-20T14:37:30+00:00');
47+
$cut2 = LastLogin::fromNative('2022-08-20T14:37:30+00:00');
48+
$cut3 = LastLogin::fromNative('2022-10-20T14:37:30+00:00');
49+
50+
$this->assertTrue($cut->equals($cut2));
51+
$this->assertFalse($cut->equals($cut3));
52+
}
4053
}

0 commit comments

Comments
 (0)