mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,39 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Entity;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testClosingEqualOpening()
|
||||
{
|
||||
$datetime = new DateTime('now');
|
||||
|
||||
$period = new AccompanyingPeriod($datetime);
|
||||
$period->setClosingDate($datetime);
|
||||
|
||||
$this->assertTrue($period->isClosingAfterOpening());
|
||||
}
|
||||
|
||||
public function testClosingIsAfterOpeningConsistency()
|
||||
{
|
||||
$datetime1 = new \DateTime('now');
|
||||
$datetime2 = new \DateTime('tomorrow');
|
||||
$datetime1 = new DateTime('now');
|
||||
$datetime2 = new DateTime('tomorrow');
|
||||
|
||||
$period = new AccompanyingPeriod($datetime1);
|
||||
$period->setClosingDate($datetime2);
|
||||
@@ -45,8 +48,8 @@ class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testClosingIsBeforeOpeningConsistency()
|
||||
{
|
||||
$datetime1 = new \DateTime('tomorrow');
|
||||
$datetime2 = new \DateTime('now');
|
||||
$datetime1 = new DateTime('tomorrow');
|
||||
$datetime2 = new DateTime('now');
|
||||
|
||||
$period = new AccompanyingPeriod($datetime1);
|
||||
$period->setClosingDate($datetime2);
|
||||
@@ -54,37 +57,53 @@ class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertFalse($period->isClosingAfterOpening());
|
||||
}
|
||||
|
||||
public function testClosingEqualOpening()
|
||||
public function testInitialComment()
|
||||
{
|
||||
$datetime = new \DateTime('now');
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
$comment = new Comment();
|
||||
$replacingComment = new Comment();
|
||||
|
||||
$period = new AccompanyingPeriod($datetime);
|
||||
$period->setClosingDate($datetime);
|
||||
$period->setInitialComment(null);
|
||||
$this->assertNull($period->getInitialComment());
|
||||
|
||||
$this->assertTrue($period->isClosingAfterOpening());
|
||||
}
|
||||
$period->setInitialComment($comment);
|
||||
$this->assertSame($period->getInitialComment(), $comment);
|
||||
$this->assertSame($period, $comment->getAccompanyingPeriod());
|
||||
$this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments');
|
||||
|
||||
public function testIsOpen()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new \DateTime());
|
||||
$period->setInitialComment($replacingComment);
|
||||
$this->assertSame($period->getInitialComment(), $replacingComment);
|
||||
$this->assertSame($period, $replacingComment->getAccompanyingPeriod());
|
||||
$this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments');
|
||||
$this->assertNull($comment->getAccompanyingPeriod());
|
||||
|
||||
$this->assertTrue($period->isOpen());
|
||||
$period->setInitialComment(null);
|
||||
$this->assertNull($period->getInitialComment());
|
||||
$this->assertNull($replacingComment->getAccompanyingPeriod());
|
||||
$this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments');
|
||||
}
|
||||
|
||||
public function testIsClosed()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new \DateTime());
|
||||
$period->setClosingDate(new \DateTime('tomorrow'));
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
$period->setClosingDate(new DateTime('tomorrow'));
|
||||
|
||||
$this->assertFalse($period->isOpen());
|
||||
}
|
||||
|
||||
public function testIsOpen()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
|
||||
$this->assertTrue($period->isOpen());
|
||||
}
|
||||
|
||||
public function testPersonPeriod()
|
||||
{
|
||||
$person = new Person();
|
||||
$person2 = new Person();
|
||||
$person3 = new Person();
|
||||
$period = new AccompanyingPeriod(new \DateTime());
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
|
||||
$participation0 = $period->createParticipationFor($person);
|
||||
$period->createParticipationFor($person2);
|
||||
@@ -104,7 +123,7 @@ class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$participationL = $period->closeParticipationFor($person);
|
||||
$this->assertSame($participationL, $participation);
|
||||
$this->assertTrue($participation->getEndDate() instanceof \DateTimeInterface);
|
||||
$this->assertTrue($participation->getEndDate() instanceof DateTimeInterface);
|
||||
|
||||
$participation = $period->getOpenParticipationContainsPerson($person);
|
||||
$this->assertNull($participation);
|
||||
@@ -125,7 +144,7 @@ class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testRequestor()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new \DateTime());
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
$person = new Person();
|
||||
$thirdParty = new ThirdParty();
|
||||
|
||||
@@ -143,35 +162,9 @@ class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertSame($thirdParty, $period->getRequestorThirdParty());
|
||||
$this->assertSame($thirdParty, $period->getRequestor());
|
||||
|
||||
$period->setRequestor(NULL);
|
||||
$period->setRequestor(null);
|
||||
$this->assertNull($period->getRequestorThirdParty());
|
||||
$this->assertNull($period->getRequestorPerson());
|
||||
$this->assertNull($period->getRequestor());
|
||||
}
|
||||
|
||||
public function testInitialComment()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new \DateTime());
|
||||
$comment = new Comment();
|
||||
$replacingComment = new Comment();
|
||||
|
||||
$period->setInitialComment(NULL);
|
||||
$this->assertNull($period->getInitialComment());
|
||||
|
||||
$period->setInitialComment($comment);
|
||||
$this->assertSame($period->getInitialComment(), $comment);
|
||||
$this->assertSame($period, $comment->getAccompanyingPeriod());
|
||||
$this->assertEquals(0, count($period->getComments()), "The initial comment should not appears in the list of comments");
|
||||
|
||||
$period->setInitialComment($replacingComment);
|
||||
$this->assertSame($period->getInitialComment(), $replacingComment);
|
||||
$this->assertSame($period, $replacingComment->getAccompanyingPeriod());
|
||||
$this->assertEquals(0, count($period->getComments()), "The initial comment should not appears in the list of comments");
|
||||
$this->assertNull($comment->getAccompanyingPeriod());
|
||||
|
||||
$period->setInitialComment(NULL);
|
||||
$this->assertNull($period->getInitialComment());
|
||||
$this->assertNull($replacingComment->getAccompanyingPeriod());
|
||||
$this->assertEquals(0, count($period->getComments()), "The initial comment should not appears in the list of comments");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user