Test Failed
Push — master ( 68ff63...99a915 )
by Vítězslav
08:13
created

FlexiBeeRWTest::testInsertToFlexiBee()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 14
nc 6
nop 0
dl 0
loc 22
rs 8.6737
c 0
b 0
f 0
1
<?php
2
3
namespace Test\FlexiPeeHP;
4
5
use FlexiPeeHP\FlexiBeeRW;
6
7
/**
8
 * Generated by PHPUnit_SkeletonGenerator on 2016-05-04 at 10:08:36.
9
 */
10
class FlexiBeeRWTest extends FlexiBeeROTest
11
{
12
    /**
13
     * Poznámka vkládaná do záznamů vytvářených během testů
14
     * @var strig 
15
     */
16
    public $poznam = 'Generováno UnitTestem PHP Knihovny https://github.com/Spoje-NET/FlexiPeeHP';
17
18
    /**
19
     *
20
     * @var array
21
     */
22
    public $insertableData = [];
23
24
    /**
25
     * @var FlexiBeeRW
26
     */
27
    protected $object;
28
29
    /**
30
     * Sets up the fixture, for example, opens a network connection.
31
     * This method is called before a test is executed.
32
     * @covers FlexiPeeHP\FlexiBeeRW::__construct
33
     */
34
    protected function setUp()
35
    {
36
        $this->object = new FlexiBeeRW();
37
    }
38
39
    /**
40
     * Tears down the fixture, for example, closes a network connection.
41
     * This method is called after a test is executed.
42
     */
43
    protected function tearDown()
44
    {
45
        
46
    }
47
48
    /**
49
     * @covers FlexiPeeHP\FlexiBeeRW::getLastInsertedId
50
     * @depends testInsertToFlexiBee
51
     */
52
    public function testGetLastInsertedId()
53
    {
54
        $this->assertNotEmpty($this->object->getLastInsertedId());
55
    }
56
57
    /**
58
     * @covers FlexiPeeHP\FlexiBeeRW::insertToFlexiBee
59
     */
60
    public function testInsertToFlexiBee()
61
    {
62
        if (empty($this->insertableData)) {
63
            $structure = $this->object->getColumnsInfo();
64
            if (array_key_exists('typDokl', $structure)) {
65
                if ($structure['typDokl']['type'] == 'relation') {
66
                    $relatedEvidence                 = basename($structure['typDokl']['url']);
67
                    $loader                          = new \FlexiPeeHP\FlexiBeeRO(null,
68
                        ['evidence' => $relatedEvidence]);
69
                    $code                            = $loader->getColumnsFromFlexibee([
70
                        'kod'], ['limit' => 1]);
71
                    $this->insertableData['typDokl'] = \FlexiPeeHP\FlexiBeeRO::code($code[0]['kod']);
72
                }
73
74
                if (array_key_exists('poznam', $structure)) {
75
                    $this->insertableData['poznam'] = $this->poznam;
76
                }
77
            }
78
        }
79
80
        $this->object->insertToFlexiBee($this->insertableData);
81
    }
82
83
    /**
84
     * @covers FlexiPeeHP\FlexiBeeRWRW::deleteFromFlexiBee
85
     */
86
    public function testDeleteFromFlexiBee()
87
    {
88
        // Remove the following lines when you implement this test.
89
        $this->markTestIncomplete(
90
            'This test has not been implemented yet.'
91
        );
92
    }
93
94
    /**
95
     * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate
96
     */
97
    public function testTimestampToFlexiDate()
98
    {
99
        $this->assertNull($this->object->timestampToFlexiDate());
100
        $this->assertEquals('2016-09-16',
101
            $this->object->timestampToFlexiDate('1474040506'));
102
    }
103
104
    /**
105
     * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDateTime
106
     */
107
    public function testTimestampToFlexiDateTime()
108
    {
109
        $this->assertNull($this->object->timestampToFlexiDateTime());
110
        $this->assertEquals('2016-09-16UTC15:41:46',
111
            $this->object->timestampToFlexiDateTime('1474040506'));
112
    }
113
}
114