Completed
Push — master ( 7483cb...a139b5 )
by Vítězslav
03:58
created

UcetniObdobiTest::testCreateYearsFrom()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 31
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 5
eloc 17
c 2
b 0
f 0
nc 9
nop 0
dl 0
loc 31
rs 8.439
1
<?php
2
/**
3
 * FlexiPeeHP - Objekt účetního období.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2015,2016 Spoje.Net
7
 */
8
9
namespace Test\FlexiPeeHP;
10
11
use FlexiPeeHP\UcetniObdobi;
12
13
/**
14
 * Generated by PHPUnit_SkeletonGenerator on 2016-04-27 at 17:32:10.
15
 */
16
class UcetniObdobiTest extends FlexiBeeTest
17
{
18
    /**
19
     * @var UcetniObdobi
20
     */
21
    protected $object;
22
23
    /**
24
     * Sets up the fixture, for example, opens a network connection.
25
     * This method is called before a test is executed.
26
     */
27
    protected function setUp()
28
    {
29
        $this->object = new UcetniObdobi;
30
    }
31
32
    /**
33
     * Tears down the fixture, for example, closes a network connection.
34
     * This method is called after a test is executed.
35
     */
36
    protected function tearDown()
37
    {
38
39
    }
40
41
    /**
42
     * @covers FlexiPeeHP\UcetniObdobi::createYearsFrom
43
     */
44
    public function testCreateYearsFrom()
45
    {
46
        //Načíst stávající roky
47
        $fbyears = $this->object->getColumnsFromFlexibee(['kod'], null, 'kod');
48
        $years   = [];
49
        foreach ($fbyears as $fbyear) {
50
            if (is_numeric($fbyear['kod'])) {
51
                $years[] = $fbyear['kod'];
52
            }
53
        }
54
        asort($years);
55
        $firstyear = current($years);
56
        $testyear  = $firstyear - 2;
57
58
59
        //Založit další dva předcházející roky
60
        $this->object->createYearsFrom($testyear, $testyear + 1);
0 ignored issues
show
Documentation introduced by
$testyear is of type integer|double, but the function expects a object<FlexiPeeHP\type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$testyear + 1 is of type double, but the function expects a object<FlexiPeeHP\type>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
61
62
        //Znovu přečíst roky z FlexiBee
63
        $newfbyears = $this->object->getColumnsFromFlexibee(['kod'], null, 'kod');
64
        $newyears   = [];
65
        foreach ($newfbyears as $newfbyear) {
66
            if (is_numeric($newfbyear['kod'])) {
67
                $newyears[$newfbyear['kod']] = $newfbyear['kod'];
68
            }
69
        }
70
71
        //Byly požadované roky založeny ?
72
        $this->assertArrayHasKey($testyear, $newyears);
73
        $this->assertArrayHasKey($testyear + 1, $newyears);
74
    }
75
}