From 93fc65ced3847a8e0837561e9fdfa0dbace2cfcb Mon Sep 17 00:00:00 2001 From: Carlos Garcia Gomez Date: Tue, 31 May 2022 12:53:15 +0200 Subject: [PATCH] =?UTF-8?q?-=20A=C3=B1adida=20comprobaci=C3=B3n=20de=20htm?= =?UTF-8?q?l=20en=20descripci=C3=B3n=20al=20test=20unitario=20del=20modelo?= =?UTF-8?q?=20cuenta.=20-=20Eliminado=20el=20test=20unitario=20de=20subcue?= =?UTF-8?q?nta=20por=20obsoleto.=20Se=20crear=C3=A1=20uno=20nuevo=20a=20co?= =?UTF-8?q?ntinuaci=C3=B3n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Model/Cuenta.php | 3 ++- Core/Translation/gl_ES.json | 2 +- Test/Core/Model/CuentaTest.php | 15 ++++++++++++ Test/Core/Model/SubcuentaTest.php | 38 ------------------------------- 4 files changed, 18 insertions(+), 40 deletions(-) delete mode 100644 Test/Core/Model/SubcuentaTest.php diff --git a/Core/Model/Cuenta.php b/Core/Model/Cuenta.php index eced8f24a6..ad0116e150 100644 --- a/Core/Model/Cuenta.php +++ b/Core/Model/Cuenta.php @@ -185,12 +185,13 @@ public static function tableName(): string public function test(): bool { $this->codcuenta = trim($this->codcuenta); + $this->descripcion = $this->toolBox()->utils()->noHtml($this->descripcion); + if (empty($this->codcuenta) || false === is_numeric($this->codcuenta)) { $this->toolBox()->i18nLog()->warning('invalid-number', ['%number%' => $this->codcuenta]); return false; } - $this->descripcion = $this->toolBox()->utils()->noHtml($this->descripcion); if (strlen($this->descripcion) < 1 || strlen($this->descripcion) > 255) { $this->toolBox()->i18nLog()->warning('invalid-column-lenght', ['%column%' => 'descripcion', '%min%' => '1', '%max%' => '255']); return false; diff --git a/Core/Translation/gl_ES.json b/Core/Translation/gl_ES.json index 3ee2436704..60c0b78bba 100644 --- a/Core/Translation/gl_ES.json +++ b/Core/Translation/gl_ES.json @@ -421,7 +421,7 @@ "emails-sent": "Emails enviados", "employees": "Empregados", "empty": "Vacío", - "empty-contact-data": "El contacto debe tener nombre o email o dirección", + "empty-contact-data": "O contacto debe ter nome ou email ou dirección", "enable": "Activar", "enable-api": "Activar API", "enable-updates-beta": "Activar actualizacións beta", diff --git a/Test/Core/Model/CuentaTest.php b/Test/Core/Model/CuentaTest.php index 2c35c734c9..4cf4301e99 100644 --- a/Test/Core/Model/CuentaTest.php +++ b/Test/Core/Model/CuentaTest.php @@ -72,6 +72,21 @@ public function testCreateBadCode() } } + public function testHtmlOnDescription() + { + $account = new Cuenta(); + $account->codcuenta = '9999'; + $account->codejercicio = $this->getRandomExercise()->codejercicio; + $account->descripcion = 'Test'; + $this->assertTrue($account->save(), 'can-not-create-account'); + + // comprobamos que el html se ha escapado + $this->assertEquals('<b>Test</b>', $account->descripcion); + + // eliminamos + $this->assertTrue($account->delete(), 'account-cant-delete'); + } + public function testCreateClosed() { // cerramos un ejercicio diff --git a/Test/Core/Model/SubcuentaTest.php b/Test/Core/Model/SubcuentaTest.php deleted file mode 100644 index f7e3d614e9..0000000000 --- a/Test/Core/Model/SubcuentaTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * Copyright (C) 2017-2018 Carlos Garcia Gomez - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -namespace FacturaScripts\Test\Core\Model; - -use FacturaScripts\Core\Model\Subcuenta; -use FacturaScripts\Test\Core\CustomTest; - -/** - * @covers \Subcuenta - * - * @author Francesc Pineda Segarra - */ -final class SubcuentaTest extends CustomTest -{ - - protected function setUp(): void - { - $this->model = new Subcuenta(); - } -}