mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Remove unrelated code style change.
This commit is contained in:
parent
48e2d2ceab
commit
03243605da
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -45,17 +45,17 @@ class AccompanyingPeriod
|
||||
|
||||
/** @var \Chill\PersonBundle\Entity\Person */
|
||||
private $person;
|
||||
|
||||
|
||||
/** @var AccompanyingPeriod\ClosingMotive */
|
||||
private $closingMotive = null;
|
||||
|
||||
|
||||
/**
|
||||
* The user making the accompanying
|
||||
*
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \DateTime $dateOpening
|
||||
@ -68,7 +68,7 @@ class AccompanyingPeriod
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
@ -84,7 +84,7 @@ class AccompanyingPeriod
|
||||
public function setOpeningDate($openingDate)
|
||||
{
|
||||
$this->openingDate = $openingDate;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -100,13 +100,17 @@ class AccompanyingPeriod
|
||||
|
||||
/**
|
||||
* Set closingDate
|
||||
*
|
||||
*
|
||||
* For closing a Person file, you should use Person::setClosed instead.
|
||||
*
|
||||
* @param \DateTime $dateClosing
|
||||
* @return AccompanyingPeriod
|
||||
*
|
||||
*/
|
||||
public function setClosingDate($closingDate)
|
||||
{
|
||||
$this->closingDate = $closingDate;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -119,12 +123,12 @@ class AccompanyingPeriod
|
||||
{
|
||||
return $this->closingDate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isOpen(): bool
|
||||
public function isOpen(): bool
|
||||
{
|
||||
if ($this->getOpeningDate() > new \DateTime('now')) {
|
||||
return false;
|
||||
@ -132,9 +136,9 @@ class AccompanyingPeriod
|
||||
|
||||
if ($this->getClosingDate() === null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,16 +152,16 @@ class AccompanyingPeriod
|
||||
if ($remark === null) {
|
||||
$remark = '';
|
||||
}
|
||||
|
||||
|
||||
$this->remark = $remark;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get remark
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function getRemark()
|
||||
{
|
||||
@ -166,7 +170,7 @@ class AccompanyingPeriod
|
||||
|
||||
/**
|
||||
* Set person.
|
||||
*
|
||||
*
|
||||
* For consistency, you should use Person::addAccompanyingPeriod instead.
|
||||
*
|
||||
* @param \Chill\PersonBundle\Entity\Person $person
|
||||
@ -176,20 +180,20 @@ class AccompanyingPeriod
|
||||
public function setPerson(\Chill\PersonBundle\Entity\Person $person = null)
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get person
|
||||
*
|
||||
* @return \Chill\PersonBundle\Entity\Person
|
||||
* @return \Chill\PersonBundle\Entity\Person
|
||||
*/
|
||||
public function getPerson()
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
|
||||
public function getClosingMotive()
|
||||
{
|
||||
return $this->closingMotive;
|
||||
@ -200,13 +204,13 @@ class AccompanyingPeriod
|
||||
$this->closingMotive = $closingMotive;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If the period can be reopened.
|
||||
*
|
||||
* This function test if the period is closed and if the period is the last
|
||||
*
|
||||
* This function test if the period is closed and if the period is the last
|
||||
* for the associated person
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canBeReOpened()
|
||||
@ -214,12 +218,12 @@ class AccompanyingPeriod
|
||||
if ($this->isOpen() === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$periods = $this->getPerson()->getAccompanyingPeriodsOrdered();
|
||||
|
||||
|
||||
return end($periods) === $this;
|
||||
}
|
||||
|
||||
|
||||
public function reOpen()
|
||||
{
|
||||
$this->setClosingDate(null);
|
||||
@ -231,29 +235,29 @@ class AccompanyingPeriod
|
||||
if ($this->isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (! $this->isClosingAfterOpening()) {
|
||||
$context->buildViolation('The date of closing is before the date of opening')
|
||||
->atPath('dateClosing')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the closing date is after the opening date.
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isClosingAfterOpening() {
|
||||
$diff = $this->getOpeningDate()->diff($this->getClosingDate());
|
||||
|
||||
|
||||
if ($diff->invert === 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
@ -262,7 +266,7 @@ class AccompanyingPeriod
|
||||
function setUser(User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Person implements HasCenterInterface {
|
||||
|
||||
/** @var string The person's last name */
|
||||
private $lastName;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
@ -121,12 +121,12 @@ class Person implements HasCenterInterface {
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
private $addresses;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $fullnameCanonical;
|
||||
|
||||
|
||||
public function __construct(\DateTime $opening = null) {
|
||||
$this->accompanyingPeriods = new ArrayCollection();
|
||||
$this->spokenLanguages = new ArrayCollection();
|
||||
@ -333,7 +333,7 @@ class Person implements HasCenterInterface {
|
||||
{
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
|
||||
public function getAltNames(): \Doctrine\Common\Collections\Collection
|
||||
{
|
||||
return $this->altNames;
|
||||
@ -342,7 +342,7 @@ class Person implements HasCenterInterface {
|
||||
public function setAltNames(\Doctrine\Common\Collections\Collection $altNames)
|
||||
{
|
||||
$this->altNames = $altNames;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -352,20 +352,20 @@ class Person implements HasCenterInterface {
|
||||
$this->altNames->add($altName);
|
||||
$altName->setPerson($this);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeAltName(PersonAltName $altName)
|
||||
|
||||
public function removeAltName(PersonAltName $altName)
|
||||
{
|
||||
if ($this->altNames->contains($altName)) {
|
||||
$altName->setPerson(null);
|
||||
$this->altNames->removeElement($altName);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set birthdate
|
||||
*
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -35,55 +35,55 @@ use Generator;
|
||||
class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* Test the creation of an accompanying, its closure and the access to
|
||||
* Test the creation of an accompanying, its closure and the access to
|
||||
* the current accompaniying period via the getCurrentAccompanyingPeriod
|
||||
* function.
|
||||
*/
|
||||
public function testGetCurrentAccompanyingPeriod()
|
||||
{
|
||||
$d = new \DateTime('yesterday');
|
||||
$d = new \DateTime('yesterday');
|
||||
$p = new Person($d);
|
||||
|
||||
|
||||
$period = $p->getCurrentAccompanyingPeriod();
|
||||
|
||||
|
||||
$this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period);
|
||||
$this->assertTrue($period->isOpen());
|
||||
$this->assertEquals($d, $period->getOpeningDate());
|
||||
|
||||
|
||||
//close and test
|
||||
$period->setClosingDate(new \DateTime('tomorrow'));
|
||||
|
||||
|
||||
$shouldBeNull = $p->getCurrentAccompanyingPeriod();
|
||||
$this->assertNull($shouldBeNull);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the getAccompanyingPeriodsOrdered function return a list of
|
||||
* periods ordered ascendency.
|
||||
*/
|
||||
public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod()
|
||||
{
|
||||
{
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
|
||||
|
||||
$e = new \DateTime("2013/3/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
|
||||
$p->close($period);
|
||||
|
||||
|
||||
$f = new \DateTime("2013/1/1");
|
||||
$p->open(new AccompanyingPeriod($f));
|
||||
|
||||
$g = new \DateTime("2013/4/1");
|
||||
|
||||
$g = new \DateTime("2013/4/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
|
||||
$p->close($period);
|
||||
|
||||
|
||||
$r = $p->getAccompanyingPeriodsOrdered();
|
||||
|
||||
|
||||
$date = $r[0]->getOpeningDate()->format('Y-m-d');
|
||||
|
||||
|
||||
$this->assertEquals($date, '2013-01-01');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the getAccompanyingPeriodsOrdered function, for periods
|
||||
* starting at the same time order regarding to the closing date.
|
||||
@ -91,25 +91,25 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
public function testAccompanyingPeriodOrderSameDateOpening() {
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
|
||||
$g = new \DateTime("2013/4/1");
|
||||
|
||||
$g = new \DateTime("2013/4/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
|
||||
$p->close($period);
|
||||
|
||||
|
||||
$f = new \DateTime("2013/2/1");
|
||||
$p->open(new AccompanyingPeriod($f));
|
||||
|
||||
|
||||
$e = new \DateTime("2013/3/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
|
||||
$p->close($period);
|
||||
|
||||
$r = $p->getAccompanyingPeriodsOrdered();
|
||||
|
||||
|
||||
$date = $r[0]->getClosingDate()->format('Y-m-d');
|
||||
|
||||
|
||||
$this->assertEquals($date, '2013-03-01');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the function checkAccompanyingPeriodIsNotCovering returns
|
||||
* the good constant when two periods are collapsing : a period
|
||||
@ -118,23 +118,23 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
public function testDateCoveringWithCoveringAccompanyingPeriod() {
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
|
||||
|
||||
$e = new \DateTime("2013/3/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
|
||||
$p->close($period);
|
||||
|
||||
|
||||
$f = new \DateTime("2013/1/1");
|
||||
$p->open(new AccompanyingPeriod($f));
|
||||
|
||||
$g = new \DateTime("2013/4/1");
|
||||
|
||||
$g = new \DateTime("2013/4/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
|
||||
$p->close($period);
|
||||
|
||||
|
||||
$r = $p->checkAccompanyingPeriodsAreNotCollapsing();
|
||||
|
||||
|
||||
$this->assertEquals($r['result'], Person::ERROR_PERIODS_ARE_COLLAPSING);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the function checkAccompanyingPeriodIsNotCovering returns
|
||||
* the good constant when two periods are collapsing : a period is open
|
||||
@ -143,16 +143,16 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
public function testNotOpenAFileReOpenedLater() {
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
|
||||
|
||||
$e = new \DateTime("2013/3/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
|
||||
$p->close($period);
|
||||
|
||||
|
||||
$f = new \DateTime("2013/1/1");
|
||||
$p->open(new AccompanyingPeriod($f));
|
||||
|
||||
|
||||
$r = $p->checkAccompanyingPeriodsAreNotCollapsing();
|
||||
|
||||
|
||||
$this->assertEquals($r['result'], Person::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user