{% set i = 0 %}
- {% for history in histories %}
+ {% for accompanying_period in accompanying_periods %}
- {{ history.dateOpening|localizeddate('long', 'none', app.request.locale) }} |
+ {{ accompanying_period.dateOpening|localizeddate('long', 'none', app.request.locale) }} |
{% spaceless %}
- {% if history.isOpen %}
+ {% if accompanying_period.isOpen %}
{{ 'Still open'|trans }}
{% else %}
- {{ history.dateClosing|localizeddate('long', 'none', app.request.locale) }}
+ {{ accompanying_period.dateClosing|localizeddate('long', 'none', app.request.locale) }}
{% endif %}
{% endspaceless %} |
|
- {% if history.memo is not empty %}
+ {% if accompanying_period.memo is not empty %}
- {{ history.memo }}
+ {{ accompanying_period.memo }}
|
{% endif %}
@@ -49,8 +49,8 @@
@@ -63,12 +63,12 @@
{% endif %}{% endspaceless %}">
{% spaceless %}
{% if person.isOpen == true %}
-
- {{'Close history'|trans }}
+
+ {{'Close accompanying period'|trans }}
{% else %}
-
- {{'Open history'|trans }}
+
+ {{'Open accompanying period'|trans }}
{% endif %}
{% endspaceless %}
diff --git a/Tests/Entity/AccompanyingPeriodTest.php b/Tests/Entity/AccompanyingPeriodTest.php
new file mode 100644
index 000000000..99bd24677
--- /dev/null
+++ b/Tests/Entity/AccompanyingPeriodTest.php
@@ -0,0 +1,101 @@
+
+ *
+ * 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
.
+ */
+
+namespace Chill\PersonBundle\Tests\Entity;
+
+use Chill\PersonBundle\Entity\AccompanyingPeriod;
+
+class AccompanyingPeriodTest extends \PHPUnit_Framework_TestCase
+{
+ public function testClosingIsAfterOpeningConsistency()
+ {
+ $datetime1 = new \DateTime('now');
+ $datetime2 = new \DateTime('tomorrow');
+
+ $period = new AccompanyingPeriod($datetime1);
+ $period->setDateClosing($datetime2);
+
+ $r = $period->isClosingAfterOpening();
+
+ $this->assertTrue($r);
+ }
+
+ public function testClosingIsBeforeOpeningConsistency() {
+ $datetime1 = new \DateTime('tomorrow');
+ $datetime2 = new \DateTime('now');
+
+ $period = new AccompanyingPeriod($datetime1);
+ $period->setDateClosing($datetime2);
+
+ $this->assertFalse($period->isClosingAfterOpening());
+ }
+
+ public function testClosingEqualOpening() {
+ $datetime = new \DateTime('now');
+
+ $period = new AccompanyingPeriod($datetime);
+ $period->setDateClosing($datetime);
+
+ $this->assertTrue($period->isClosingAfterOpening());
+ }
+
+ public function testIsOpen() {
+ $period = new AccompanyingPeriod(new \DateTime());
+
+ $this->assertTrue($period->isOpen());
+ }
+
+ public function testIsClosed() {
+ $period = new AccompanyingPeriod(new \DateTime());
+ $period->setDateClosing(new \DateTime('tomorrow'));
+
+ $this->assertFalse($period->isOpen());
+ }
+
+ /**
+ * This test seems only to test ordering datetime... Maybe delete ?
+ */
+ public function testOrder() {
+ $d = new \DateTime(); $d->setDate(2013, 2, 1);
+ $g = new \DateTime(); $g->setDate(2013, 4, 1);
+ $f = new \DateTime(); $f->setDate(2013, 1, 1);
+ $e = new \DateTime(); $e->setDate(2013,3,1);
+
+ $a = array($d, $g, $f, $e);
+
+ usort($a, function($a, $b) {
+ if ($a === $b) {
+ return 0;
+ }
+
+ if ($a < $b) {
+ return -1;
+ } else {
+ return 1;
+ }
+ });
+
+ $date = $a[0]->format('Y-m-d');
+
+ $this->assertEquals($date, '2013-01-01');
+ }
+}
\ No newline at end of file
diff --git a/Tests/Entity/HistoryFileTest.php b/Tests/Entity/HistoryFileTest.php
deleted file mode 100644
index 095a3cf6a..000000000
--- a/Tests/Entity/HistoryFileTest.php
+++ /dev/null
@@ -1,103 +0,0 @@
-setDateClosing($datetime2);
-
-
- $r = $history->isClosingAfterOpening();
-
- $this->assertTrue($r);
- }
-
- public function testClosingIsBeforeOpeningConsistency() {
- $datetime1 = new \DateTime('tomorrow');
-
-
- $history = new PersonHistoryFile($datetime1);
-
-
- $datetime2 = new \DateTime('now');
-
- $history->setDateClosing($datetime2);
-
- $this->assertFalse($history->isClosingAfterOpening());
- }
-
- public function testClosingEqualOpening() {
- $datetime = new \DateTime('now');
-
- $history = new PersonHistoryFile($datetime);
- $history->setDateClosing($datetime);
-
- $this->assertTrue($history->isClosingAfterOpening());
- }
-
- public function testIsOpen() {
- $history = new PersonHistoryFile(new \DateTime());
-
- $this->assertTrue($history->isOpen());
- }
-
- public function testIsClosed() {
- $history = new PersonHistoryFile(new \DateTime());
-
- $history->setDateClosing(new \DateTime('tomorrow'));
-
- $this->assertFalse($history->isOpen());
- }
-
-
-
-
-
-
-
- /**
- * This test seems only to test ordering datetime... Maybe delete ?
- */
- public function testOrder() {
- $d = new \DateTime(); $d->setDate(2013, 2, 1);
- $g = new \DateTime(); $g->setDate(2013, 4, 1);
- $f = new \DateTime(); $f->setDate(2013, 1, 1);
- $e = new \DateTime(); $e->setDate(2013,3,1);
-
- $a = array($d, $g, $f, $e);
-
-
- usort($a, function($a, $b) {
- if ($a === $b) {
- return 0;
- }
-
- if ($a < $b) {
- return -1;
- } else {
- return 1;
- }
- });
-
-
- $date = $a[0]->format('Y-m-d');
-
- $this->assertEquals($date, '2013-01-01');
-
- }
-
-
-
-}
diff --git a/Tests/Entity/PersonTest.php b/Tests/Entity/PersonTest.php
index f2b721af9..5a7eef2f4 100644
--- a/Tests/Entity/PersonTest.php
+++ b/Tests/Entity/PersonTest.php
@@ -2,7 +2,7 @@
/*
* Chill is a software for social workers
- * Copyright (C) 2014 Julien Fastré
+ * Copyright (C) 2014-2015 Champs-Libres Coopérative
*
* 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
@@ -21,7 +21,7 @@
namespace Chill\PersonBundle\Tests\Entity;
use Chill\PersonBundle\Entity\Person;
-use Chill\PersonBundle\Entity\PersonHistoryFile;
+use Chill\PersonBundle\Entity\AccompanyingPeriod;
/**
* Unit tests on person
@@ -30,106 +30,102 @@ use Chill\PersonBundle\Entity\PersonHistoryFile;
*/
class PersonTest extends \PHPUnit_Framework_TestCase
{
- public function testGetCurrentHistory()
+ public function testGetCurrentAccompanyingPeriod()
{
$d = new \DateTime('yesterday');
$p = new Person($d);
- $history = $p->getCurrentHistory();
+ $period = $p->getCurrentAccompanyingPeriod();
- $this->assertInstanceOf('Chill\PersonBundle\Entity\PersonHistoryFile', $history);
- $this->assertTrue($history->isOpen());
- $this->assertEquals($d, $history->getDateOpening());
+ $this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period);
+ $this->assertTrue($period->isOpen());
+ $this->assertEquals($d, $period->getDateOpening());
//close and test
- $history->setDateClosing(new \DateTime('tomorrow'));
+ $period->setDateClosing(new \DateTime('tomorrow'));
- $shouldBeNull = $p->getCurrentHistory();
+ $shouldBeNull = $p->getCurrentAccompanyingPeriod();
$this->assertNull($shouldBeNull);
}
- public function testHistoryOrderWithUnorderedHistory() {
+ public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod() {
$d = new \DateTime();
$d->setDate(2013, 2, 1);
$p = new Person($d);
$e = new \DateTime();
$e->setDate(2013, 3, 1);
- $history = $p->getCurrentHistory()->setDateClosing($e);
- $p->close($history);
+ $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e);
+ $p->close($period);
$f = new \DateTime();
$f->setDate(2013, 1, 1);
- $p->open(new PersonHistoryFile($f));
+ $p->open(new AccompanyingPeriod($f));
$g = new \DateTime();
$g->setDate(2013, 4, 1);
- $history = $p->getCurrentHistory()->setDateClosing($g);
- $p->close($history);
+ $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($g);
+ $p->close($period);
- $r = $p->getHistoriesOrdered();
+ $r = $p->getAccompanyingPeriodsOrdered();
$date = $r[0]->getDateOpening()->format('Y-m-d');
-
$this->assertEquals($date, '2013-01-01');
}
- public function testHistoryOrderSameDateOpening() {
+ public function testAccompanyingPeriodOrderSameDateOpening() {
$d = new \DateTime();
$d->setDate(2013, 2, 1);
$p = new Person($d);
$e = new \DateTime();
$e->setDate(2013, 3, 1);
- $history = $p->getCurrentHistory()->setDateClosing($e);
- $p->close($history);
+ $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e);
+ $p->close($period);
$f = new \DateTime();
$f->setDate(2013, 2, 1);
- $p->open(new PersonHistoryFile($f));
+ $p->open(new AccompanyingPeriod($f));
$g = new \DateTime();
$g->setDate(2013, 4, 1);
- $history = $p->getCurrentHistory()->setDateClosing($g);
- $p->close($history);
+ $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($g);
+ $p->close($period);
- $r = $p->getHistoriesOrdered();
+ $r = $p->getAccompanyingPeriodsOrdered();
$date = $r[0]->getDateClosing()->format('Y-m-d');
-
$this->assertEquals($date, '2013-03-01');
}
- public function testDateCoveringWithCoveringHistory() {
+ public function testDateCoveringWithCoveringAccompanyingPeriod() {
$d = new \DateTime();
$d->setDate(2013, 2, 1);
$p = new Person($d);
$e = new \DateTime();
$e->setDate(2013, 3, 1);
- $history = $p->getCurrentHistory()->setDateClosing($e);
- $p->close($history);
+ $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e);
+ $p->close($period);
$f = new \DateTime();
$f->setDate(2013, 1, 1);
- $p->open(new PersonHistoryFile($f));
+ $p->open(new AccompanyingPeriod($f));
$g = new \DateTime();
$g->setDate(2013, 4, 1);
- $history = $p->getCurrentHistory()->setDateClosing($g);
- $p->close($history);
+ $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($g);
+ $p->close($period);
- $r = $p->checkHistoryIsNotCovering();
+ $r = $p->checkAccompanyingPeriodIsNotCovering();
$this->assertEquals($r['result'], Person::ERROR_OPENING_IS_INSIDE_CLOSING);
}
-
-
public function testNotOpenAFileReOpenedLater() {
$d = new \DateTime();
$d->setDate(2013, 2, 1);
@@ -137,15 +133,14 @@ class PersonTest extends \PHPUnit_Framework_TestCase
$e = new \DateTime();
$e->setDate(2013, 3, 1);
- $history = $p->getCurrentHistory()->setDateClosing($e);
- $p->close($history);
+ $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e);
+ $p->close($period);
$f = new \DateTime();
$f->setDate(2013, 1, 1);
- $p->open(new PersonHistoryFile($f));
-
+ $p->open(new AccompanyingPeriod($f));
- $r = $p->checkHistoryIsNotCovering();
+ $r = $p->checkAccompanyingPeriodIsNotCovering();
$this->assertEquals($r['result'], Person::ERROR_OPENING_NOT_CLOSED_IS_BEFORE_NEW_LINE);
}