Compare commits

...

16 Commits

Author SHA1 Message Date
afa04f3599 Merge branch 'bootstrap-tests-ci' into bootstrap-tests-ci.fix 2021-04-20 21:39:05 +02:00
d765eecb8e Merge remote-tracking branch 'origin/master' into bootstrap-tests-ci 2021-04-20 21:38:53 +02:00
82daf1e3af add extensions to postgres 2021-04-20 21:36:25 +02:00
7719447044 use test base image 2021-04-20 21:10:16 +02:00
23892043a5 fix postgres service name 2021-04-20 18:16:39 +02:00
d7bc93580f fix gitlab-ci 2021-04-20 18:15:04 +02:00
a7e4900690 Add .gitlab-ci.yml 2021-04-20 15:32:41 +00:00
e98a5b88aa fix some tests in main bundle 2021-04-20 17:21:39 +02:00
1b42656e0f bootstrap to be run on root bundle 2021-04-20 17:20:57 +02:00
e9674dd334 fixtures: really find Charline 2021-04-20 15:14:15 +02:00
0fcec73a62 Merge branch 'v8-entity-parcours-fixes' into 'master'
Fix some stuff in AccompanyingPeriod

See merge request Chill-Projet/chill-bundles!13
2021-04-20 12:53:07 +00:00
9539214d24 add some constants string to constants 2021-04-19 13:34:03 +02:00
c5b4a44ff3 AccompanyingPeriodParticipation: set cascade=persist for accompanyingPeriod
fixes : A new entity was found through the relationship 'Chill\PersonBundle\Entity\AccompanyingPeriodParticipation#accompanyingPeriod'
that was not configured t  o cascade persist operations for entity: Chill\PersonBundle\Entity\AccompanyingPeriod@0000000002b1d44a000000002510e4e2.
To solve this issue: Either explici   tly call EntityManager#persist() on this unknown entity or configure
cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem
implement 'Chill\PersonBundle\Entity\AccompanyingPeriod#__toString()' to get a clue.
2021-04-19 13:32:19 +02:00
b7d6d29fac AccompanyingPeriod/ClosingMotive: fix json_array deprecated 2021-04-19 13:29:17 +02:00
51e9b1fcf2 AccompanyingPeriod/Origin: set label as json 2021-04-19 13:25:13 +02:00
b490f4a82c fix migration for parcours - rename sequence for closing motive 2021-04-19 12:58:47 +02:00
19 changed files with 323 additions and 36 deletions

64
.env Normal file
View File

@@ -0,0 +1,64 @@
##
## Manually dump .env files in .env.local.php with
## `$ composer symfony:dump-env prod`
##
## Project environment
APP_ENV=dev
## Enable debug
APP_DEBUG=true
## Locale
LOCALE=fr
## Framework secret
APP_SECRET=ThisTokenIsNotSoSecretChangeIt
## Symfony/swiftmailer
MAILER_TRANSPORT=smtp
MAILER_HOST=smtp
MAILER_PORT=1025
MAILER_CRYPT=
MAILER_AUTH=
MAILER_USER=
MAILER_PASSWORD=
MAILER_URL=${MAILER_TRANSPORT}://${MAILER_HOST}:${MAILER_PORT}?encryption=${MAILER_CRYPT}&auth_mode=${MAILER_AUTH}&username=${MAILER_USER}&password=${MAILER_PASSWORD}
## Notifications
NOTIFICATION_HOST=localhost:8001
NOTIFICATION_FROM_EMAIL=admin@chill.social
NOTIFICATION_FROM_NAME=Chill
## Gelf
GELF_HOST=gelf
GELF_PORT=12201
## OVH OpenStack Storage User/Role
OS_USERNAME=
OS_PASSWORD=
OS_TENANT_ID=
OS_REGION_NAME=GRA
OS_AUTH_URL=https://auth.cloud.ovh.net/v2.0/
## OVH OpenStack Storage Container
ASYNC_UPLOAD_TEMP_URL_KEY=
ASYNC_UPLOAD_TEMP_URL_BASE_PATH=
ASYNC_UPLOAD_TEMP_URL_CONTAINER=
## Redis Cache
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}
## Twilio
TWILIO_SID=~
TWILIO_SECRET=~
## DOCKER IMAGES REGISTRY
#IMAGE_PHP=
#IMAGE_NGINX=
## DOCKER IMAGES VERSION
#VERSION=test
VERSION=prod

6
.env.test Normal file
View File

@@ -0,0 +1,6 @@
# variables for .env environement
# those variables suits for gitlab-ci
# Run tests from root to adapt your own environment
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres?serverVersion=12&charset=utf8

16
.gitignore vendored
View File

@@ -1,3 +1,19 @@
.composer/*
composer.phar
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
/bin/
###< symfony/framework-bundle ###
###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

37
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,37 @@
---
image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
# Select what we should cache between builds
cache:
paths:
- tests/app/vendor/
before_script:
# add extensions to postgres
- PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;"
# Install and run Composer
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
- php tests/app/bin/console doctrine:migrations:migrate -n
- php tests/app/bin/console doctrine:fixtures:load -n
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
services:
- name: postgres:12
alias: db
- name: redis
alias: redis
# Set any variables we need
variables:
# Configure postgres environment variables (https://hub.docker.com/r/_/postgres/)
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# fetch the chill-app using git submodules
GIT_SUBMODULE_STRATEGY: recursive
# Run our tests
test:
script:
- bin/phpunit --colors=never

3
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "_exts/sphinx-php"]
path = _exts/sphinx-php
url = https://github.com/fabpot/sphinx-php.git
[submodule "tests/app"]
path = tests/app
url = https://gitlab.com/Chill-projet/chill-app.git

View File

@@ -19,10 +19,14 @@
"Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle"
}
},
"autoload-dev": {
"psr-4": {
"App\\": "tests/app/src/"
}
},
"require": {
"champs-libres/async-uploader-bundle": "dev-sf4",
"graylog2/gelf-php": "^1.5",
"symfony/flex": "^1.9",
"symfony/form": "4.*",
"symfony/twig-bundle": "^4.4",
"twig/extra-bundle": "^2.12|^3.0",
@@ -66,6 +70,17 @@
"symfony/stopwatch": "^5.1",
"symfony/web-profiler-bundle": "^5.0",
"symfony/var-dumper": "4.*",
"symfony/debug-bundle": "^5.1"
"symfony/debug-bundle": "^5.1",
"symfony/phpunit-bridge": "^5.2"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
},
"config": {
"vendor-dir": "tests/app/vendor",
"bin-dir": "bin"
}
}

38
phpunit.xml.dist Normal file
View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/app/tests/bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
<server name="SHELL_VERBOSITY" value="-1" />
</php>
<testsuites>
<testsuite name="MainBundle">
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
</testsuite>
<testsuite name="PersonBundle">
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
-->
</phpunit>

View File

@@ -34,7 +34,7 @@ trait PrepareClientTrait
* @return \Symfony\Component\BrowserKit\Client
* @throws \LogicException
*/
public function getClient(
public function getClientAuthenticated(
$username = 'center a_social',
$password = 'password'
) {

View File

@@ -1,13 +0,0 @@
<?php
namespace Chill\MainBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
public function testIndex()
{
}
}

View File

@@ -45,11 +45,6 @@ class ExportManagerTest extends KernelTestCase
use \Chill\MainBundle\Test\PrepareUserTrait;
use \Chill\MainBundle\Test\PrepareScopeTrait;
/**
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
private $container;
/**
*
@@ -65,8 +60,6 @@ class ExportManagerTest extends KernelTestCase
{
self::bootKernel();
$this->container = self::$kernel->getContainer();
$this->prophet = new \Prophecy\Prophet;
}
@@ -97,7 +90,7 @@ class ExportManagerTest extends KernelTestCase
\Symfony\Component\Security\Core\User\UserInterface $user = null
)
{
$localUser = $user === NULL ? $this->container->get('doctrine.orm.entity_manager')
$localUser = $user === NULL ? self::$container->get('doctrine.orm.entity_manager')
->getRepository('ChillMainBundle:User')
->findOneBy(array('username' => 'center a_social')) :
$user;
@@ -106,10 +99,10 @@ class ExportManagerTest extends KernelTestCase
$tokenStorage->setToken($token);
return new ExportManager(
$logger === NULL ? $this->container->get('logger') : $logger,
$em === NULL ? $this->container->get('doctrine.orm.entity_manager') : $em,
$authorizationChecker === NULL ? $this->container->get('security.authorization_checker') : $authorizationChecker,
$authorizationHelper === NULL ? $this->container->get('chill.main.security.authorization.helper') : $authorizationHelper,
$logger === NULL ? self::$container->get('logger') : $logger,
$em === NULL ? self::$container->get('doctrine.orm.entity_manager') : $em,
$authorizationChecker === NULL ? self::$container->get('security.authorization_checker') : $authorizationChecker,
$authorizationHelper === NULL ? self::$container->get('chill.main.security.authorization.helper') : $authorizationHelper,
$tokenStorage)
;
}
@@ -544,7 +537,7 @@ class ExportManagerTest extends KernelTestCase
$export = $this->prophet->prophesize();
$export->willImplement(ExportInterface::class);
$em = $this->container->get('doctrine.orm.entity_manager');
$em = self::$container->get('doctrine.orm.entity_manager');
$export->initiateQuery(
Argument::is(array('foo')),
Argument::Type('array'),
@@ -627,7 +620,7 @@ class ExportManagerTest extends KernelTestCase
//add formatter interface
$formatter = new \Chill\MainBundle\Export\Formatter\SpreadSheetFormatter(
$this->container->get('translator'), $exportManager);
self::$container->get('translator'), $exportManager);
$exportManager->addFormatter($formatter, 'spreadsheet');
//ob_start();

View File

@@ -42,7 +42,37 @@ use Chill\MainBundle\Entity\User;
*/
class AccompanyingPeriod
{
const INTENSITY = ['occasional', 'regular'];
/**
* Mark an accompanying period as "occasional"
*
* used in INTENSITY
*/
public const INTENSITY_OCCASIONAL = 'occasional';
/**
* Mark an accompanying period as "regular"
*
* used in INTENSITY
*/
public const INTENSITY_REGULAR = 'regular';
public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR];
/**
* Mark an accompanying period as "draft".
*
* This means that the accompanying period is not yet
* confirmed by the creator
*/
public const STEP_DRAFT = 'DRAFT';
/**
* Mark an accompanying period as "confirmed".
*
* This means that the accompanying period **is**
* confirmed by the creator
*/
public const STEP_CONFIRMED = 'CONFIRMED';
/**
* @var integer
@@ -117,7 +147,7 @@ class AccompanyingPeriod
* @var string
* @ORM\Column(type="string", length=32, nullable=true)
*/
private $step = 'DRAFT';
private $step = self::STEP_DRAFT;
/**
* @ORM\ManyToOne(targetEntity=Origin::class)

View File

@@ -47,7 +47,7 @@ class ClosingMotive
/**
* @var array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;

View File

@@ -39,7 +39,7 @@ class Origin
private $id;
/**
* @ORM\Column(type="string", length=255)
* @ORM\Column(type="json")
*/
private $label;

View File

@@ -50,7 +50,7 @@ class AccompanyingPeriodParticipation
private $person;
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations")
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
*/
private $accompanyingPeriod;

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Rename sequence "closing motive"
*/
final class Version20210419105054 extends AbstractMigration
{
public function getDescription() : string
{
return 'rename sequence "closing motive"';
}
public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_closingmotive_id_seq RENAME TO '
. 'chill_person_accompanying_period_closingmotive_id_seq');
}
public function down(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive_id_seq '
. 'RENAME TO chill_person_closingmotive_id_seq');
}
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* set label for origin as json
*/
final class Version20210419105940 extends AbstractMigration
{
public function getDescription() : string
{
return 'set label for origin as json';
}
public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label TYPE JSON USING json_build_object(\'fr\', label)::jsonb');
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label DROP DEFAULT');
}
public function down(Schema $schema) : void
{
// this will keep the '"' at first and last character, but is acceptable
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label TYPE VARCHAR(255) USING label->\'fr\'::text');
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label DROP DEFAULT');
}
}

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* fix deprecated json array
*/
final class Version20210419112619 extends AbstractMigration
{
public function getDescription() : string
{
return 'fix deprecated json_array';
}
public function up(Schema $schema) : void
{
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS NULL');
}
public function down(Schema $schema) : void
{
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
}
}

View File

@@ -89,7 +89,7 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co
{
$charline = $this->container->get('doctrine.orm.entity_manager')
->getRepository('ChillPersonBundle:Person')
->findOneBy(array('lastName' => 'Charline'))
->findOneBy(array('firstName' => 'Charline', 'lastName' => 'Depardieu'))
;
$report = (new Report())

1
tests/app Submodule

Submodule tests/app added at 88bd6e9ea0