Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Añadida comprobación de html en descripción al test unitario del mo…
…delo cuenta.

- Eliminado el test unitario de subcuenta por obsoleto. Se creará uno nuevo a continuación.
  • Loading branch information
NeoRazorX committed May 31, 2022
1 parent ee599c4 commit 93fc65c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 40 deletions.
3 changes: 2 additions & 1 deletion Core/Model/Cuenta.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Core/Translation/gl_ES.json
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions Test/Core/Model/CuentaTest.php
Expand Up @@ -72,6 +72,21 @@ public function testCreateBadCode()
}
}

public function testHtmlOnDescription()
{
$account = new Cuenta();
$account->codcuenta = '9999';
$account->codejercicio = $this->getRandomExercise()->codejercicio;
$account->descripcion = '<b>Test</b>';
$this->assertTrue($account->save(), 'can-not-create-account');

// comprobamos que el html se ha escapado
$this->assertEquals('&lt;b&gt;Test&lt;/b&gt;', $account->descripcion);

// eliminamos
$this->assertTrue($account->delete(), 'account-cant-delete');
}

public function testCreateClosed()
{
// cerramos un ejercicio
Expand Down
38 changes: 0 additions & 38 deletions Test/Core/Model/SubcuentaTest.php

This file was deleted.

0 comments on commit 93fc65c

Please sign in to comment.