Passed
Push — master ( 64043f...33d76f )
by Carlos
04:40
created

FormaPagoTest::testCreateWithNoCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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()) {
0 ignored issues
show
Bug introduced by
The method isDefault() does not exist on FacturaScripts\Core\Model\Base\ModelClass. It seems like you code against a sub-type of said class. However, the method does not exist in FacturaScripts\Core\Model\Base\Contact or FacturaScripts\Core\Model\Base\Address or FacturaScripts\Dinamic\Model\Base\ModelClass or FacturaScripts\Core\Model\Base\ModelOnChangeClass or FacturaScripts\Core\Model\Base\BankAccount or FacturaScripts\Core\Model\Base\Payment or FacturaScripts\Core\Model\Base\ReportAccounting or FacturaScripts\Dinamic\Model\Base\Contact or FacturaScripts\Core\Model\Base\ComercialContact or FacturaScripts\Dinamic\Model\Base\ComercialContact or FacturaScripts\Dinamic\Model\Base\Address or FacturaScripts\Core\Model\Base\Receipt or FacturaScripts\Core\Mode...se\BusinessDocumentLine or FacturaScripts\Dinamic\M...Base\ModelOnChangeClass or FacturaScripts\Core\Model\Base\BusinessDocument or FacturaScripts\Dinamic\Model\Base\Receipt or FacturaScripts\Dinamic\M...se\BusinessDocumentLine or FacturaScripts\Core\Mode...se\PurchaseDocumentLine or FacturaScripts\Core\Model\Base\SalesDocumentLine or FacturaScripts\Dinamic\M...se\PurchaseDocumentLine or FacturaScripts\Dinamic\M...\Base\SalesDocumentLine or FacturaScripts\Dinamic\Model\Base\BusinessDocument or FacturaScripts\Core\Model\Base\TransformerDocument or FacturaScripts\Core\Model\Base\PurchaseDocument or FacturaScripts\Dinamic\M...ase\TransformerDocument or FacturaScripts\Core\Model\Base\SalesDocument or FacturaScripts\Dinamic\Model\Base\PurchaseDocument or FacturaScripts\Dinamic\Model\Base\SalesDocument or FacturaScripts\Dinamic\Model\Base\BankAccount or FacturaScripts\Dinamic\Model\Base\Payment or FacturaScripts\Dinamic\Model\Base\ReportAccounting. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
            if ($row->/** @scrutinizer ignore-call */ isDefault()) {
Loading history...
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