|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Test\FlexiPeeHP; |
|
4
|
|
|
|
|
5
|
|
|
use FlexiPeeHP\FakturaVydana; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-04-27 at 17:32:11. |
|
9
|
|
|
*/ |
|
10
|
|
|
class FakturaVydanaTest extends FlexiBeeRWTest |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var FakturaVydana |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $object; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
19
|
|
|
* This method is called before a test is executed. |
|
20
|
|
|
*/ |
|
21
|
|
|
protected function setUp() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->object = new FakturaVydana(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
28
|
|
|
* This method is called after a test is executed. |
|
29
|
|
|
*/ |
|
30
|
|
|
protected function tearDown() |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @covers FlexiPeeHP\FakturaVydana::hotovostniUhrada |
|
37
|
|
|
*/ |
|
38
|
|
|
public function testhotovostniUhrada() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->makeInvoice(); |
|
41
|
|
|
$this->object->unsetDataValue('kod'); |
|
42
|
|
|
$this->object->hotovostniUhrada($this->object->getDataValue('sumCelkZakl')); |
|
43
|
|
|
$this->assertEquals(201, $this->object->lastResponseCode, |
|
44
|
|
|
_('Invoice settle error')); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @covers FlexiPeeHP\FakturaVydana::sparujPlatbu |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testsparujPlatbu() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->makeInvoice(); |
|
53
|
|
|
$doklad = new \FlexiPeeHP\PokladniPohyb(); |
|
54
|
|
|
$value = $this->object->getDataValue('sumCelkZakl'); |
|
55
|
|
|
$dataPohybu = [ |
|
56
|
|
|
'kod' => 'FP'.time(), |
|
57
|
|
|
'typDokl' => 'code:STANDARD', |
|
58
|
|
|
'typPohybuK' => 'typPohybu.prijem', |
|
59
|
|
|
'datVyst' => date("Y-m-d", time() - 60 * 60 * 24), |
|
60
|
|
|
'jakUhrK' => 'jakUhrazeno.rucne1', |
|
61
|
|
|
'pokladna' => 'code:POKLADNA KČ', |
|
62
|
|
|
'generovatSkl' => false, |
|
63
|
|
|
'zdrojProSkl' => false, |
|
64
|
|
|
'firma' => $this->object->getDataValue('firma'), |
|
65
|
|
|
'bezPolozek' => true, |
|
66
|
|
|
'poznam' => $this->poznam, |
|
67
|
|
|
'primUcet' => 'code:013001', |
|
68
|
|
|
'sumZklCelkem' => $value |
|
69
|
|
|
]; |
|
70
|
|
|
$doklad->takeData($dataPohybu); |
|
71
|
|
|
$doklad->insertToFlexiBee(); |
|
72
|
|
|
$doklad->unsetDataValue('kod'); |
|
73
|
|
|
$this->object->sparujPlatbu($doklad); |
|
74
|
|
|
$this->assertEquals(201, $doklad->lastResponseCode, |
|
75
|
|
|
_('Invoice match error')); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Crerate testing invoice |
|
80
|
|
|
* |
|
81
|
|
|
* @param array $invoiceData |
|
82
|
|
|
*/ |
|
83
|
|
|
public function makeInvoice($invoiceData = []) |
|
84
|
|
|
{ |
|
85
|
|
|
if (!isset($invoiceData['kod'])) { |
|
86
|
|
|
$invoiceData['kod'] = 'PeeHP'.time(); |
|
87
|
|
|
} |
|
88
|
|
|
if (!isset($invoiceData['varSym'])) { |
|
89
|
|
|
$invoiceData['varSym'] = \Ease\Sand::randomNumber(1000, 99999); |
|
90
|
|
|
} |
|
91
|
|
|
if (!isset($invoiceData['datVyst'])) { |
|
92
|
|
|
$invoiceData['datVyst'] = date("Y-m-d", time() - 60 * 60 * 24); |
|
93
|
|
|
} |
|
94
|
|
|
if (!isset($invoiceData['typDokl'])) { |
|
95
|
|
|
$invoiceData['typDokl'] = 'code:FAKTURA'; |
|
96
|
|
|
} |
|
97
|
|
|
if (!isset($invoiceData['zdrojProSkl'])) { |
|
98
|
|
|
$invoiceData['zdrojProSkl'] = false; |
|
99
|
|
|
} |
|
100
|
|
|
if (!isset($invoiceData['dobropisovano'])) { |
|
101
|
|
|
$invoiceData['dobropisovano'] = false; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if (!isset($invoiceData['polozky'])) { |
|
105
|
|
|
$invoiceData['bezPolozek'] = true; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
if (!isset($invoiceData['sumCelkZakl'])) { |
|
109
|
|
|
$scale = pow(1000, 2); |
|
110
|
|
|
$invoiceData['sumCelkZakl'] = round(mt_rand(10 * $scale, |
|
111
|
|
|
9000 * $scale) / $scale, 2); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
if (!isset($invoiceData['firma'])) { |
|
115
|
|
|
$adresar = new \FlexiPeeHP\Adresar(); |
|
116
|
|
|
|
|
117
|
|
|
$adresy = $adresar->getFlexiData(null, |
|
118
|
|
|
['typVztahuK' => 'typVztahu.odberatel']); |
|
119
|
|
|
|
|
120
|
|
|
$dodavatel = $adresy[array_rand($adresy)]; |
|
121
|
|
|
|
|
122
|
|
|
$invoiceData['firma'] = 'code:'.$dodavatel['kod']; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
if (!isset($ivoiceData['poznam'])) { |
|
|
|
|
|
|
126
|
|
|
$invoiceData['poznam'] = $this->poznam; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
$this->object->takeData($invoiceData); |
|
130
|
|
|
$result = $this->object->insertToFlexiBee(); |
|
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
$id = $this->object->getLastInsertedId(); |
|
133
|
|
|
$this->object->setDataValue('id', $id); |
|
134
|
|
|
return $id; |
|
135
|
|
|
} |
|
136
|
|
|
} |
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.