mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
writing test to reproduce bug
This commit is contained in:
parent
5ade08d549
commit
c205bbddd3
@ -24,6 +24,7 @@ namespace Chill\PersonBundle\Tests\Entity;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
|
||||
/**
|
||||
* Unit tests for the person Entity
|
||||
@ -151,4 +152,47 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals($r['result'], Person::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD);
|
||||
}
|
||||
|
||||
public function testGetLastAddress()
|
||||
{
|
||||
$date0 = (\DateTime::createFromFormat('Y-m-d', '2021-02-05'))->settime(0,0);
|
||||
$date1 = (\DateTime::createFromFormat('Y-m-d', '2021-03-05'))->settime(0,0);
|
||||
$date2 = (\DateTime::createFromFormat('Y-m-d', '2021-04-05'))->settime(0,0);
|
||||
$date3 = (\DateTime::createFromFormat('Y-m-d', '2021-05-05'))->settime(0,0);
|
||||
$date4 = (\DateTime::createFromFormat('Y-m-d', '2021-06-05'))->settime(0,0);
|
||||
$date5 = (\DateTime::createFromFormat('Y-m-d', '2021-07-05'))->settime(0,0);
|
||||
$date6 = (\DateTime::createFromFormat('Y-m-d', '2021-08-05'))->settime(0,0);
|
||||
$p = new Person($date1);
|
||||
|
||||
$this->assertNull($p->getLastAddress($date1));
|
||||
|
||||
// add some address
|
||||
$add1 = (new Address())->setValidFrom($date1);
|
||||
// no address with date 2
|
||||
$add3 = (new Address())->setValidFrom($date3);
|
||||
// no address with date 4
|
||||
$add5 = (new Address())->setValidFrom($date5);
|
||||
|
||||
$p->addAddress($add1);
|
||||
|
||||
// test that, if only one address, that does work:
|
||||
$this->assertSame($add1, $p->getLastAddress($date1));
|
||||
$this->assertSame($add1, $p->getLastAddress($date2));
|
||||
$this->assertSame($add1, $p->getLastAddress());
|
||||
|
||||
// adress before the date should not work
|
||||
$this->assertNull($p->getLastAddress($date0));
|
||||
|
||||
// add addresses
|
||||
$p->addAddress($add3);
|
||||
$p->addAddress($add5);
|
||||
|
||||
// test retrieval of address
|
||||
$this->assertSame($add1, $p->getLastAddress($date2));
|
||||
//$this->assertSame($add3, $p->getLastAddress($date3));
|
||||
dump($p->getLastAddress($date4), $add3);
|
||||
$this->assertSame($add3, $p->getLastAddress($date4));
|
||||
//$this->assertSame($add5, $p->getLastAddress($date5));
|
||||
$this->assertSame($add5, $p->getLastAddress($date6));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user