mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
tests: Add missing test based on review's feedback.
This commit is contained in:
parent
c73e497d94
commit
55d963641e
@ -172,7 +172,7 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
$p = new Person($date);
|
||||
|
||||
// Make sure that there is no last address.
|
||||
$this->assertNull($p->getLastAddress());
|
||||
$this::assertNull($p->getLastAddress());
|
||||
|
||||
// Take an arbitrary date before the $date in parameter.
|
||||
$addressDate = $date->sub(new DateInterval('PT180M'));
|
||||
@ -181,21 +181,29 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
$address1 = (new Address())->setValidFrom($addressDate);
|
||||
$p->addAddress($address1);
|
||||
|
||||
$this->assertCount(1, $p->getAddresses());
|
||||
$this->assertSame($address1, $p->getLastAddress());
|
||||
$this::assertCount(1, $p->getAddresses());
|
||||
$this::assertSame($address1, $p->getLastAddress());
|
||||
|
||||
// 2. Add an older address, which should not be the last address.
|
||||
$address2 = (new Address())->setValidFrom($addressDate->sub(new DateInterval('PT30M')));
|
||||
$addressDate2 = $addressDate->sub(new DateInterval('PT30M'));
|
||||
$address2 = (new Address())->setValidFrom($addressDate2);
|
||||
$p->addAddress($address2);
|
||||
|
||||
$this->assertCount(2, $p->getAddresses());
|
||||
$this->assertSame($address1, $p->getLastAddress());
|
||||
$this::assertCount(2, $p->getAddresses());
|
||||
$this::assertSame($address1, $p->getLastAddress());
|
||||
|
||||
// 3. Add a newer address, which should be the last address.
|
||||
$address3 = (new Address())->setValidFrom($addressDate->add(new DateInterval('PT30M')));
|
||||
$addressDate3 = $addressDate->add(new DateInterval('PT30M'));
|
||||
$address3 = (new Address())->setValidFrom($addressDate3);
|
||||
$p->addAddress($address3);
|
||||
|
||||
$this->assertCount(3, $p->getAddresses());
|
||||
$this->assertSame($address3, $p->getLastAddress());
|
||||
$this::assertCount(3, $p->getAddresses());
|
||||
$this::assertSame($address3, $p->getLastAddress());
|
||||
|
||||
// 4. Get the last address from a specific date.
|
||||
$this::assertSame($address1, $p->getLastAddress($addressDate));
|
||||
$this::assertSame($address2, $p->getLastAddress($addressDate2));
|
||||
$this::assertSame($address3, $p->getLastAddress($addressDate3));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user