Commit 7ff955d9 authored by Ines RUIZ's avatar Ines RUIZ

Merge branch '1131-report-pastell3-0-9-master' into 'master'

Resolve "report pastell3.0.9 -> master"

Closes #1096 and #1131

See merge request libriciel/pole-plate-formes/pastell/pastell!566
parents 1f31e470 dba5db51
Pipeline #11123 canceled with stages
......@@ -5,6 +5,16 @@
- Ajout d'une étape studio de transformation (création de meta-données ou de fichiers supplémentaires)
- Ajout d'un connecteur de transformation générique, permettant d'utiliser du Twig, du xpath et du jsonpath pour créer de nouvelles métadonnées #994
# [3.0.9] - 2020-09-07
## Correction
- Erreur lors de la création d'un flux studio quand le titre est positionné sur un fichier #1096
## Évolutions
- Permettre l'utilisation d'un proxy authentifié sur la constante HTTP_PROXY_URL #1107
# [3.0.8] - 2020-08-03
## Correction
......
......@@ -47,6 +47,9 @@ class ModificationAction extends ActionExecutor
//Mise à jour du titre
$titre_field = $this->getFormulaire()->getTitreField();
$titre = $this->getDonneesFormulaire()->get($titre_field);
if (is_array($titre)) {
$titre = $titre[0] ?? $this->id_d;
}
$this->getDocument()->setTitre($this->id_d, $titre);
if (
......
......@@ -25,6 +25,8 @@ class SoapClientFactory
$url_part = parse_url($this->http_proxy_url);
$options['proxy_host'] = $url_part['host'];
$options['proxy_port'] = $url_part['port'];
$options['proxy_login'] = $url_part['user'] ?? '';
$options['proxy_password'] = $url_part['pass'] ?? '';
stream_context_set_option(
$options['stream_context'],
......
......@@ -239,7 +239,7 @@ class TypeDossierEtapeManager
{
$type_dossier_path = $this->extensions->getTypeDossierPath($etape->type);
if (! $type_dossier_path) {
return false;
return $result;
}
$type_dossier_etape_class = glob($type_dossier_path . "/TypeDossier*Etape.class.php");
......
......@@ -127,7 +127,9 @@ class TypeDossierTranslator
private function getEnvoiTypeLibelle(TypeDossierEtapeProperties $typeDossierEtape): string
{
$all_type = $this->typeDossierEtapeDefinition->getAllType();
if (empty($all_type[$typeDossierEtape->type])) {
return "";
}
$result = $all_type[$typeDossierEtape->type];
if (!$typeDossierEtape->etape_with_same_type_exists) {
return $result;
......
<?php
require_once __DIR__ . "/pastell-core/type-dossier/TypeDossierLoader.class.php";
trait TypeDossierLoaderTestTrait
{
/**
* @param $type_dossier_file_path
* @throws TypeDossierException
*/
protected function loadTypeDossier($type_dossier_file_path)
{
$this->getObjectInstancier()
->getInstance(TypeDossierLoader::class)
->createTypeDossierFromFilepath($type_dossier_file_path);
}
protected function unloadTypeDossier()
{
$this->getObjectInstancier()
->getInstance(TypeDossierLoader::class)
->unload();
}
/**
* @return ObjectInstancier
*/
abstract public function getObjectInstancier();
}
......@@ -2,7 +2,10 @@
class ModificationActionTest extends PastellTestCase
{
use TypeDossierLoaderTestTrait;
private const FILENAME_FIXTURE = 'foo.pdf';
private const TYPE_DOSSIER_FIXTURE_PATH = __DIR__ . "/fixtures/test-bug-1096.json";
/**
* @throws NotFoundException
*/
......@@ -49,7 +52,7 @@ class ModificationActionTest extends PastellTestCase
$this->expectExceptionMessage("Le contenu de arrete n'est pas éditable");
$this->getInternalAPI()->post(
"/Entite/1/Document/$id_d/file/arrete",
['file_content' => 'test', 'file_name' => 'foo']
['file_content' => 'test', 'file_name' => self::FILENAME_FIXTURE]
);
$donneesFormulaire = $this->getDonneesFormulaireFactory()->get($id_d);
......@@ -68,7 +71,7 @@ class ModificationActionTest extends PastellTestCase
"/Entite/1/Document/$id_d/file/arrete",
[
'file_content' => file_get_contents(__DIR__ . "/../fixtures/vide.pdf"),
'file_name' => 'foo.pdf'
'file_name' => self::FILENAME_FIXTURE
]
);
......@@ -79,4 +82,41 @@ class ModificationActionTest extends PastellTestCase
$donneesFormulaire->getFileContent('arrete')
);
}
/**
* @throws TypeDossierException
*/
public function testWhenTitreFieldIsAfile()
{
$this->loadTypeDossier(self::TYPE_DOSSIER_FIXTURE_PATH);
$result = $this->createDocumentTestBug1096();
$this->assertEquals(self::FILENAME_FIXTURE, $result['content']['info']['titre']);
$this->unloadTypeDossier();
}
/**
* @throws TypeDossierException
*/
public function testWhenDeleteAFileField()
{
$this->loadTypeDossier(self::TYPE_DOSSIER_FIXTURE_PATH);
$result = $this->createDocumentTestBug1096();
$id_d = $result['content']['info']['id_d'];
$result = $this->getInternalAPI()->delete("/Entite/1/Document/$id_d/file/un_fichier");
$this->assertEquals($id_d, $result['info']['titre']);
$this->unloadTypeDossier();
}
private function createDocumentTestBug1096()
{
$id_d = $this->createDocument('test-bug-1096')['id_d'];
return $this->getInternalAPI()->post(
"/Entite/1/Document/$id_d/file/un_fichier",
[
'file_content' => 'bar',
'file_name' => self::FILENAME_FIXTURE
]
);
}
}
{
"id_type_dossier": "test-bug-1096",
"pastell-version": "%VERSION%",
"timestamp": 1598510173,
"raw_data": {
"nom": "test-bug-1096",
"type": "Types de dossier personnalis\u00e9s",
"etape": [
{
"type": "depot",
"requis": "on",
"num_etape": 0,
"automatique": "on",
"specific_type_info": [],
"num_etape_same_type": 0,
"etape_with_same_type_exists": false
}
],
"nom_onglet": "onglet1",
"description": "",
"id_type_dossier": "test-bug-1096",
"formulaireElement": [
{
"name": "Un fichier",
"type": "file",
"titre": "on",
"requis": "",
"element_id": "un_fichier",
"preg_match": "",
"commentaire": "",
"select_value": "",
"champs_affiches": "",
"preg_match_error": "",
"champs_recherche_avancee": ""
}
]
}
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ require_once __DIR__ . '/PastellTestCase.class.php';
require_once __DIR__ . "/SoapUtilitiesTestTrait.php";
require_once __DIR__ . "/CurlUtilitiesTestTrait.php";
require_once __DIR__ . "/TypeDossierLoaderTestTrait.php";
require_once(__DIR__ . "/../../init-no-db.php");
......
......@@ -52,4 +52,13 @@ class TypeDossierEtapeManagerTest extends PastellTestCase
$redisWrapper = $this->getObjectInstancier()->getInstance(MemoryCache::class);
$redisWrapper->flushAll();
}
public function testEtapeDoesNotExists()
{
$etape = new TypeDossierEtapeProperties();
$etape->type = 'foo';
$initial_result = ['formulaire' => [],'action' => []];
$result = $this->getTypeDossierEtapeManager()->setSpecificData($etape, $initial_result);
$this->assertEquals($initial_result, $result);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment