mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 03:08:25 +00:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			2.12.0
			...
			behaviour/
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 81a8a6ed03 | |||
| 19bfeacc9a | |||
| 692e63aba3 | 
@@ -252,18 +252,6 @@ final class PersonController extends AbstractController
 | 
			
		||||
         */
 | 
			
		||||
        $person = $form->getData();
 | 
			
		||||
 | 
			
		||||
        $periods = $person->getAccompanyingPeriodsOrdered();
 | 
			
		||||
        $period = $periods[0];
 | 
			
		||||
        $period->setOpeningDate($form['creation_date']->getData());
 | 
			
		||||
//        $person = new Person($form['creation_date']->getData());
 | 
			
		||||
//
 | 
			
		||||
//        $person->setFirstName($form['firstName']->getData())
 | 
			
		||||
//                ->setLastName($form['lastName']->getData())
 | 
			
		||||
//                ->setGender($form['gender']->getData())
 | 
			
		||||
//                ->setBirthdate($form['birthdate']->getData())
 | 
			
		||||
//                ->setCenter($form['center']->getData())
 | 
			
		||||
//                ;
 | 
			
		||||
 | 
			
		||||
        return $person;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -364,7 +352,6 @@ final class PersonController extends AbstractController
 | 
			
		||||
                'lastName' => $form['lastName']->getData(),
 | 
			
		||||
                'birthdate' => $form['birthdate']->getData(),
 | 
			
		||||
                'gender' => $form['gender']->getData(),
 | 
			
		||||
                'creation_date' => $form['creation_date']->getData(),
 | 
			
		||||
                'form' => $form->createView()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -183,6 +183,14 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
 | 
			
		||||
    private function addAPerson(array $person, ObjectManager $manager)
 | 
			
		||||
    {
 | 
			
		||||
        $p = new Person();
 | 
			
		||||
        $p->addAccompanyingPeriod(
 | 
			
		||||
            new AccompanyingPeriod(
 | 
			
		||||
                (new \DateTime())
 | 
			
		||||
                    ->sub(
 | 
			
		||||
                        new \DateInterval('P'.\random_int(0, 180).'D')
 | 
			
		||||
                    )
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        foreach ($person as $key => $value) {
 | 
			
		||||
            switch ($key) {
 | 
			
		||||
 
 | 
			
		||||
@@ -379,12 +379,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
 | 
			
		||||
     */
 | 
			
		||||
    private Collection $householdAddresses;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Person constructor.
 | 
			
		||||
     *
 | 
			
		||||
     * @param \DateTime|null $opening
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(\DateTime $opening = null)
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        $this->accompanyingPeriodParticipations = new ArrayCollection();
 | 
			
		||||
        $this->spokenLanguages = new ArrayCollection();
 | 
			
		||||
@@ -393,12 +388,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
 | 
			
		||||
        $this->otherPhoneNumbers = new ArrayCollection();
 | 
			
		||||
        $this->householdParticipations = new ArrayCollection();
 | 
			
		||||
        $this->householdAddresses = new ArrayCollection();
 | 
			
		||||
 | 
			
		||||
        if ($opening === null) {
 | 
			
		||||
            $opening = new \DateTime();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->open(new AccompanyingPeriod($opening));
 | 
			
		||||
        $this->genderComment = new CommentEmbeddable();
 | 
			
		||||
        $this->maritalStatusComment = new CommentEmbeddable();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Component\OptionsResolver\OptionsResolver;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
 | 
			
		||||
use Chill\MainBundle\Form\Type\ChillDateType;
 | 
			
		||||
use Chill\MainBundle\Form\Type\CenterType;
 | 
			
		||||
use Chill\PersonBundle\Form\Type\GenderType;
 | 
			
		||||
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
 | 
			
		||||
@@ -80,9 +80,6 @@ final class CreationPersonType extends AbstractType
 | 
			
		||||
                        'property_path' => 'birthdate'
 | 
			
		||||
                    ))
 | 
			
		||||
                    ->add('gender', HiddenType::class)
 | 
			
		||||
                    ->add('creation_date', HiddenType::class, array(
 | 
			
		||||
                        'mapped' => false
 | 
			
		||||
                    ))
 | 
			
		||||
                    ->add('form_status', HiddenType::class, array(
 | 
			
		||||
                        'mapped' => false,
 | 
			
		||||
                        'data' => $options['form_status']
 | 
			
		||||
@@ -99,25 +96,18 @@ final class CreationPersonType extends AbstractType
 | 
			
		||||
            
 | 
			
		||||
            $builder->get('birthdate')
 | 
			
		||||
                    ->addModelTransformer($dateToStringTransformer);
 | 
			
		||||
            $builder->get('creation_date')
 | 
			
		||||
                    ->addModelTransformer($dateToStringTransformer);
 | 
			
		||||
            $builder->get('center')
 | 
			
		||||
                    ->addModelTransformer($this->centerTransformer);
 | 
			
		||||
        } else {
 | 
			
		||||
            $builder
 | 
			
		||||
                ->add('firstName')
 | 
			
		||||
                ->add('lastName')
 | 
			
		||||
                ->add('birthdate', DateType::class, array('required' => false,
 | 
			
		||||
                    'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
 | 
			
		||||
                ->add('birthdate', ChillDateType::class, [
 | 
			
		||||
                    'required' => false,
 | 
			
		||||
                ])
 | 
			
		||||
                ->add('gender', GenderType::class, array(
 | 
			
		||||
                    'required' => true, 'placeholder' => null
 | 
			
		||||
                ))
 | 
			
		||||
                ->add('creation_date', DateType::class, array(
 | 
			
		||||
                    'required' => true,
 | 
			
		||||
                    'widget' => 'single_text',
 | 
			
		||||
                    'format' => 'dd-MM-yyyy',
 | 
			
		||||
                    'mapped' => false,
 | 
			
		||||
                    'data' => new \DateTime()))
 | 
			
		||||
                ->add('form_status', HiddenType::class, array(
 | 
			
		||||
                    'data' => $options['form_status'],
 | 
			
		||||
                    'mapped' => false
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
{#
 | 
			
		||||
 * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * * 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.
 | 
			
		||||
@@ -38,8 +37,6 @@
 | 
			
		||||
                {{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }}
 | 
			
		||||
                            
 | 
			
		||||
                {{ form_row(form.gender, { 'label' : 'Gender'|trans }) }} 
 | 
			
		||||
                            
 | 
			
		||||
                {{ form_row(form.creation_date, { 'label' : 'Creation date'|trans }) }}             
 | 
			
		||||
                    
 | 
			
		||||
                {{ form_rest(form) }}
 | 
			
		||||
                
 | 
			
		||||
 
 | 
			
		||||
@@ -71,14 +71,15 @@
 | 
			
		||||
                        <dd>{{ person|chill_entity_render_string }}</dd>
 | 
			
		||||
                        
 | 
			
		||||
                        <dt>{{ 'Date of birth'|trans }}</dt>
 | 
			
		||||
                        <dd>{{ birthdate|format_date('long')|default( 'Unknown date of birth'|trans ) }}</dd>
 | 
			
		||||
                        {% if birthdate is empty %}
 | 
			
		||||
                          <dd>{{ 'Unknown date of birth'|trans }}</dd>
 | 
			
		||||
                        {% else %}
 | 
			
		||||
                          <dd>{{ birthdate|format_date('long') }}</dd>
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                        
 | 
			
		||||
                        <dt>{{ 'Gender'|trans }}</dt>
 | 
			
		||||
                        <dd>{{ gender|trans }}</dd>
 | 
			
		||||
                        
 | 
			
		||||
                        <dt>{{ 'Creation date'|trans }}</dt>
 | 
			
		||||
                        <dd>{{ creation_date|format_date('long') }}</dd>
 | 
			
		||||
                        
 | 
			
		||||
                        {% if form.altNames is defined %}
 | 
			
		||||
                            {# mark as rendered #}
 | 
			
		||||
                            {{ form_widget(form.altNames) }}
 | 
			
		||||
@@ -86,10 +87,13 @@
 | 
			
		||||
                    </dl>
 | 
			
		||||
                    
 | 
			
		||||
                    {{ form_rest(form) }}
 | 
			
		||||
                    <button class="btn btn-submit" type="submit"><i class="fa fa-check"></i> {{ 'Confirm the creation'|trans }}</button>
 | 
			
		||||
                    <ul class="record_actions">
 | 
			
		||||
                      <li>
 | 
			
		||||
                        <button class="sc-button bt-create change-icon" type="submit"><i class="fa fa-check"></i> {{ 'Confirm the creation'|trans }}</button>
 | 
			
		||||
                      </li>
 | 
			
		||||
                    </ul>
 | 
			
		||||
                {{ form_end(form) }}
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</div>    
 | 
			
		||||
 
 | 
			
		||||
@@ -93,8 +93,6 @@ class PersonControllerCreateTest extends WebTestCase
 | 
			
		||||
              'The page contains a "gender" input');
 | 
			
		||||
        $this->assertTrue($form->has(self::BIRTHDATE_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);
 | 
			
		||||
        $this->assertEquals('radio', $genderType->getType(), 
 | 
			
		||||
@@ -107,10 +105,6 @@ class PersonControllerCreateTest extends WebTestCase
 | 
			
		||||
              'gender has "femme" option');
 | 
			
		||||
        $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;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -45,11 +45,12 @@ class PersonTest extends \PHPUnit\Framework\TestCase
 | 
			
		||||
    public function testGetCurrentAccompanyingPeriod()
 | 
			
		||||
    {
 | 
			
		||||
        $d = new \DateTime('yesterday'); 
 | 
			
		||||
        $p = new Person($d);
 | 
			
		||||
        $p = new Person();
 | 
			
		||||
        $p->addAccompanyingPeriod(new AccompanyingPeriod($d));
 | 
			
		||||
        
 | 
			
		||||
        $period = $p->getCurrentAccompanyingPeriod();
 | 
			
		||||
        
 | 
			
		||||
        $this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period);
 | 
			
		||||
        $this->assertInstanceOf(AccompanyingPeriod::class, $period);
 | 
			
		||||
        $this->assertTrue($period->isOpen());
 | 
			
		||||
        $this->assertEquals($d, $period->getOpeningDate());
 | 
			
		||||
        
 | 
			
		||||
@@ -67,7 +68,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
 | 
			
		||||
    public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod()
 | 
			
		||||
    {       
 | 
			
		||||
        $d = new \DateTime("2013/2/1");
 | 
			
		||||
        $p = new Person($d);
 | 
			
		||||
        $p = new Person();
 | 
			
		||||
        $p->addAccompanyingPeriod(new AccompanyingPeriod($d));
 | 
			
		||||
        
 | 
			
		||||
        $e = new \DateTime("2013/3/1");
 | 
			
		||||
        $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
 | 
			
		||||
@@ -93,7 +95,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testAccompanyingPeriodOrderSameDateOpening() {
 | 
			
		||||
        $d = new \DateTime("2013/2/1");
 | 
			
		||||
        $p = new Person($d);
 | 
			
		||||
        $p = new Person();
 | 
			
		||||
        $p->addAccompanyingPeriod(new AccompanyingPeriod($d));
 | 
			
		||||
        
 | 
			
		||||
        $g = new \DateTime("2013/4/1"); 
 | 
			
		||||
        $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
 | 
			
		||||
@@ -120,7 +123,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testDateCoveringWithCoveringAccompanyingPeriod() {
 | 
			
		||||
        $d = new \DateTime("2013/2/1");
 | 
			
		||||
        $p = new Person($d);
 | 
			
		||||
        $p = new Person();
 | 
			
		||||
        $p->addAccompanyingPeriod(new AccompanyingPeriod($d));
 | 
			
		||||
        
 | 
			
		||||
        $e = new \DateTime("2013/3/1");
 | 
			
		||||
        $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
 | 
			
		||||
@@ -145,7 +149,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testNotOpenAFileReOpenedLater() {
 | 
			
		||||
        $d = new \DateTime("2013/2/1");
 | 
			
		||||
        $p = new Person($d);
 | 
			
		||||
        $p = new Person();
 | 
			
		||||
        $p->addAccompanyingPeriod(new AccompanyingPeriod($d));
 | 
			
		||||
        
 | 
			
		||||
        $e = new \DateTime("2013/3/1");
 | 
			
		||||
        $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
 | 
			
		||||
 
 | 
			
		||||
@@ -20,9 +20,11 @@
 | 
			
		||||
 | 
			
		||||
namespace Chill\PersonBundle\Tests\Timeline;
 | 
			
		||||
 | 
			
		||||
use Symfony\Bundle\SecurityBundle\Tests\Functional\WebTestCase;
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Chill\MainBundle\Test\PrepareClientTrait;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class tests entries are shown for closing and opening 
 | 
			
		||||
@@ -31,22 +33,20 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
 | 
			
		||||
 * @author Julien Fastré <julien.fastre@champs-libres.coop>
 | 
			
		||||
 * @author Champs Libres <info@champs-libres.coop>
 | 
			
		||||
 */
 | 
			
		||||
class TimelineAccompanyingPeriodTest extends \Chill\PersonBundle\Tests\Controller\AccompanyingPeriodControllerTest
 | 
			
		||||
class TimelineAccompanyingPeriodTest extends WebTestCase
 | 
			
		||||
{
 | 
			
		||||
    public function testEntriesAreShown() 
 | 
			
		||||
    use PrepareClientTrait;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @dataProvider provideDataPersonWithAccompanyingPeriod
 | 
			
		||||
     */
 | 
			
		||||
    public function testEntriesAreShown($personId) 
 | 
			
		||||
    {
 | 
			
		||||
        $this->generatePeriods(array(
 | 
			
		||||
            [
 | 
			
		||||
                'openingDate' => '2014-01-01',
 | 
			
		||||
                'closingDate' => '2014-12-31',
 | 
			
		||||
                'closingMotive' => $this->getRandomClosingMotive()
 | 
			
		||||
            ]
 | 
			
		||||
        ));
 | 
			
		||||
        $client = $this->getClientAuthenticated();
 | 
			
		||||
 | 
			
		||||
        $crawler = $client->request('GET', "/en/person/{$personId}/timeline");
 | 
			
		||||
        
 | 
			
		||||
        $crawler = $this->client->request('GET', '/en/person/'
 | 
			
		||||
              .$this->person->getId().'/timeline');
 | 
			
		||||
        
 | 
			
		||||
        $this->assertTrue($this->client->getResponse()->isSuccessful(),
 | 
			
		||||
        $this->assertTrue($client->getResponse()->isSuccessful(),
 | 
			
		||||
              "the timeline page loads sucessfully");
 | 
			
		||||
        $this->assertGreaterThan(0, $crawler->filter('.timeline div')->count(),
 | 
			
		||||
              "the timeline page contains multiple div inside a .timeline element");
 | 
			
		||||
@@ -57,5 +57,34 @@ class TimelineAccompanyingPeriodTest extends \Chill\PersonBundle\Tests\Controlle
 | 
			
		||||
              $crawler->Filter('.timeline')->text(),
 | 
			
		||||
              "the text 'Une période d'accompagnement a été fermée' is present");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function provideDataPersonWithAccompanyingPeriod()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $qb = self::$container->get(EntityManagerInterface::class)
 | 
			
		||||
                              ->createQueryBuilder()
 | 
			
		||||
                          ;
 | 
			
		||||
        $personIds = $qb
 | 
			
		||||
            ->from(Person::class, 'p')
 | 
			
		||||
            ->join('p.accompanyingPeriodParticipations', 'part')
 | 
			
		||||
            ->join('part.accompanyingPeriod', 'period')
 | 
			
		||||
            ->join('p.center', 'center')
 | 
			
		||||
            ->select('p.id')
 | 
			
		||||
            ->where($qb->expr()->isNotNull('period.closingDate'))
 | 
			
		||||
            ->andWhere($qb->expr()->eq('center.name', ':center'))
 | 
			
		||||
            ->setParameter('center', 'Center A')
 | 
			
		||||
            ->setMaxResults(1000)
 | 
			
		||||
            ->getQuery()
 | 
			
		||||
            ->getResult()
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        \shuffle($personIds);
 | 
			
		||||
 | 
			
		||||
        yield [ \array_pop($personIds)['id'] ];
 | 
			
		||||
        yield [ \array_pop($personIds)['id'] ];
 | 
			
		||||
        yield [ \array_pop($personIds)['id'] ];
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
   
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user