1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of FacturaScripts |
4
|
|
|
* Copyright (C) 2017-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\FormaPago; |
23
|
|
|
use FacturaScripts\Test\Core\LogErrorsTrait; |
24
|
|
|
use PHPUnit\Framework\TestCase; |
25
|
|
|
|
26
|
|
|
final class FormaPagoTest extends TestCase |
27
|
|
|
{ |
28
|
|
|
use LogErrorsTrait; |
29
|
|
|
|
30
|
|
|
public function testCreate() |
31
|
|
|
{ |
32
|
|
|
$payment = new FormaPago(); |
33
|
|
|
$payment->codpago = 'Test'; |
34
|
|
|
$payment->descripcion = 'Test Payment Method'; |
35
|
|
|
$this->assertTrue($payment->save(), 'payment-method-cant-save'); |
36
|
|
|
$this->assertNotNull($payment->primaryColumnValue(), 'payment-method-not-stored'); |
37
|
|
|
$this->assertTrue($payment->exists(), 'payment-method-cant-persist'); |
38
|
|
|
$this->assertTrue($payment->delete(), 'payment-method-cant-delete'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testCreateWithNoCode() |
42
|
|
|
{ |
43
|
|
|
$payment = new FormaPago(); |
44
|
|
|
$payment->descripcion = 'Test Payment Method'; |
45
|
|
|
$this->assertTrue($payment->save(), 'payment-method-cant-save'); |
46
|
|
|
$this->assertTrue($payment->delete(), 'payment-method-cant-delete'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testDeleteDefault() |
50
|
|
|
{ |
51
|
|
|
$payment = new FormaPago(); |
52
|
|
|
foreach ($payment->all([], [], 0, 0) as $row) { |
53
|
|
|
if ($row->isDefault()) { |
|
|
|
|
54
|
|
|
$this->assertFalse($row->delete(), 'payment-method-default-cant-delete'); |
55
|
|
|
break; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
protected function tearDown() |
61
|
|
|
{ |
62
|
|
|
$this->logErrors(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|