Passed
Push — master ( b8d1dd...8de7b7 )
by Carlos
04:38
created

PaisTest::testCreateNoCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of FacturaScripts
4
 * Copyright (C) 2021 Carlos Garcia Gomez <[email protected]>
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation, either version 3 of the
9
 * License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
namespace FacturaScripts\Test\Core\Model;
21
22
use FacturaScripts\Core\Model\Pais;
23
use FacturaScripts\Test\Core\LogErrorsTrait;
24
use PHPUnit\Framework\TestCase;
25
26
final class PaisTest extends TestCase
27
{
28
    use LogErrorsTrait;
29
30
    public function testDataInstalled()
31
    {
32
        $pais = new Pais();
33
        $this->assertNotEmpty($pais->all(), 'pais-data-not-installed-from-csv');
34
    }
35
36
    public function testCreate()
37
    {
38
        $pais = new Pais();
39
        $pais->codpais = 'YOL';
40
        $pais->nombre = 'Yolandia';
41
        $this->assertTrue($pais->save(), 'pais-can-not-create');
42
        $this->assertTrue($pais->exists(), 'pais-do-not-persists');
43
        $this->assertTrue($pais->delete(), 'pais-can-not-delete');
44
    }
45
46
    public function testCreateNoCode()
47
    {
48
        $pais = new Pais();
49
        $pais->nombre = 'Wolandia';
50
        $this->assertFalse($pais->save(), 'pais-can-not-create');
51
    }
52
53
    protected function tearDown()
54
    {
55
        $this->logErrors();
56
    }
57
}
58