Issues (232)

Test/main/ClienteTest.php (4 issues)

1
<?php
2
/*
3
 * Copyright (C) 2025 Joe Nilson <[email protected]>
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as
7
 * published by the Free Software Foundation, either version 3 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Lesser General Public License for more details.
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace FacturaScripts\Test\Plugins;
19
20
use FacturaScripts\Dinamic\Model\Cliente;
0 ignored issues
show
The type FacturaScripts\Dinamic\Model\Cliente was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use FacturaScripts\Test\Traits\LogErrorsTrait;
0 ignored issues
show
The type FacturaScripts\Test\Traits\LogErrorsTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use PHPUnit\Framework\TestCase;
0 ignored issues
show
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
24
class ClienteTest extends TestCase
25
{
26
    use LogErrorsTrait;
27
    public static function setUpBeforeClass(): void
28
    {
29
        $listaCliente = new Cliente();
0 ignored issues
show
The assignment to $listaCliente is dead and can be removed.
Loading history...
30
    }
31
32
    public function testCreate()
33
    {
34
        $consumidorFinal = new Cliente();
35
        $consumidorFinal->idcliente = 1;
36
        $consumidorFinal->nombre = 'Razon Social';
37
        $consumidorFinal->direccion = 'Direccion';
38
        $consumidorFinal->telefono = 'Telefono';
39
        $consumidorFinal->email = 'Email';
40
        $consumidorFinal->cuit = 'CI';
41
        $consumidorFinal->personafisica = true;
42
        $consumidorFinal->cifnif = '1234567890';
43
        $consumidorFinal->codpago = 'CONT';
44
        $consumidorFinal->tipoidfiscal = 'CI';
45
        $consumidorFinal->tipocomprobante = 'CI';
46
        $consumidorFinal->ncftipopago = 'CI';
47
        $consumidorFinal->regimeniva = 'General';
48
        $this->assertTrue($consumidorFinal->save(), 'cliente-can-save');
49
        $this->assertTrue($consumidorFinal->save(), 'cliente-cant-save');
50
        $this->assertNotNull($consumidorFinal->primaryColumnValue(), 'cliente-not-stored');
51
        $this->assertTrue($consumidorFinal->exists(), 'cliente-cant-persist');
52
53
        // razón social es igual a nombre
54
        $this->assertEquals($consumidorFinal->nombre, $consumidorFinal->razonsocial);
55
56
        // comprobamos que se ha creado una dirección por defecto
57
        $addresses = $consumidorFinal->getAddresses();
58
        $this->assertCount(1, $addresses, 'cliente-default-address-not-created');
59
        foreach ($addresses as $address) {
60
            $this->assertEquals($address->cifnif, $consumidorFinal->cifnif);
61
            $this->assertEquals($address->codagente, $consumidorFinal->codagente);
62
            $this->assertEquals($address->codcliente, $consumidorFinal->codcliente);
63
            $this->assertEquals($address->idcontacto, $consumidorFinal->idcontactofact);
64
        }
65
66
        // eliminamos
67
        $this->assertTrue($consumidorFinal->getDefaultAddress()->delete(), 'contacto-cant-delete');
68
        $this->assertTrue($consumidorFinal->delete(), 'cliente-cant-delete');
69
70
    }
71
}
72