fix tests

This commit is contained in:
Julien Fastré 2021-07-20 17:32:16 +02:00
parent 692e63aba3
commit 19bfeacc9a
2 changed files with 11 additions and 12 deletions

View File

@ -93,8 +93,6 @@ class PersonControllerCreateTest extends WebTestCase
'The page contains a "gender" input'); 'The page contains a "gender" input');
$this->assertTrue($form->has(self::BIRTHDATE_INPUT), $this->assertTrue($form->has(self::BIRTHDATE_INPUT),
'The page has a "date of birth" input'); 'The page has a "date of birth" input');
$this->assertTrue($form->has(self::CREATEDATE_INPUT),
'The page contains a "creation date" input');
$genderType = $form->get(self::GENDER_INPUT); $genderType = $form->get(self::GENDER_INPUT);
$this->assertEquals('radio', $genderType->getType(), $this->assertEquals('radio', $genderType->getType(),
@ -107,10 +105,6 @@ class PersonControllerCreateTest extends WebTestCase
'gender has "femme" option'); 'gender has "femme" option');
$this->assertFalse($genderType->hasValue(), 'The gender input is not checked'); $this->assertFalse($genderType->hasValue(), 'The gender input is not checked');
$today = new \DateTime();
$this->assertEquals($today->format('d-m-Y'), $form->get(self::CREATEDATE_INPUT)
->getValue(), 'The creation date input has the current date by default');
return $form; return $form;
} }

View File

@ -45,11 +45,12 @@ class PersonTest extends \PHPUnit\Framework\TestCase
public function testGetCurrentAccompanyingPeriod() public function testGetCurrentAccompanyingPeriod()
{ {
$d = new \DateTime('yesterday'); $d = new \DateTime('yesterday');
$p = new Person($d); $p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$period = $p->getCurrentAccompanyingPeriod(); $period = $p->getCurrentAccompanyingPeriod();
$this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period); $this->assertInstanceOf(AccompanyingPeriod::class, $period);
$this->assertTrue($period->isOpen()); $this->assertTrue($period->isOpen());
$this->assertEquals($d, $period->getOpeningDate()); $this->assertEquals($d, $period->getOpeningDate());
@ -67,7 +68,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod() public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod()
{ {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new \DateTime("2013/3/1"); $e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
@ -93,7 +95,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
*/ */
public function testAccompanyingPeriodOrderSameDateOpening() { public function testAccompanyingPeriodOrderSameDateOpening() {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$g = new \DateTime("2013/4/1"); $g = new \DateTime("2013/4/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
@ -120,7 +123,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDateCoveringWithCoveringAccompanyingPeriod() { public function testDateCoveringWithCoveringAccompanyingPeriod() {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new \DateTime("2013/3/1"); $e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
@ -145,7 +149,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
*/ */
public function testNotOpenAFileReOpenedLater() { public function testNotOpenAFileReOpenedLater() {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new \DateTime("2013/3/1"); $e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);