Issues (158)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/TestCase.php (27 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Moip\Tests;
4
5
use Moip\Auth\OAuth;
6
use Moip\Moip;
7
use Moip\Resource\Customer;
8
use Moip\Resource\Holder;
9
use Moip\Resource\Orders;
10
use PHPUnit\Framework\TestCase as BaseTestCase;
11
use Requests_Response;
12
13
/**
14
 * class TestCase.
15
 */
16
abstract class TestCase extends BaseTestCase
17
{
18
    /**
19
     * Variables representing the test modes. On MOCK mode no http request will be made.
20
     * In SANDBOX mode HTTP requests will be made to the Moip::SANDBOX_ENDPOINT, the authentication information
21
     * is retrieved from the MOIP_TOKEN and MOIP_KEY environment variables.
22
     */
23
    const MOCK = 'mock';
24
    const SANDBOX = 'sandbox';
25
26
    /**
27
     * Intance of \Moip\Moip.
28
     *
29
     * @var \Moip\Moip
30
     * */
31
    protected $moip;
32
33
    /**
34
     * @var string current format for dates.
35
     */
36
    protected $date_format = 'Y-m-d';
37
38
    /**
39
     * @var string date used for testing.
40
     */
41
    protected $date_string = '1989-06-01';
42
    //todo: add the ability to use the play(https://github.com/rodrigosaito/mockwebserver-player) files from the jada sdk
43
    //the two responses below were based on the moip Java sdk's test files (https://github.com/moip/moip-sdk-java/)
44
    /**
45
     * @var string response from the client moip API.
46
     */
47
    protected $body_client;
48
49
    /**
50
     * @var string response from the order moip API.
51
     */
52
    protected $body_order;
53
54
    /**
55
     * @var string response from moip API.
56
     */
57
    protected $body_cc_pay_pci;
58
59
    /**
60
     * @var string response from moip API.
61
     */
62
    protected $body_cc_pay_pci_store;
63
64
    /**
65
     * @var string response from moip API.
66
     */
67
    protected $body_cc_pay_pci_escrow;
68
69
    /**
70
     * @var string response from moip API.
71
     */
72
    protected $body_release_escrow;
73
74
    /**
75
     * @var string response from moip API.
76
     */
77
    protected $body_billet_pay;
78
79
    /**
80
     * @var string response from moip API.
81
     */
82
    protected $body_refund_full_bankaccount;
83
84
    /**
85
     * @var string response from moip API.
86
     */
87
    protected $body_refund_partial_bankaccount;
88
89
    /**
90
     * @var string response from moip API.
91
     */
92
    protected $body_notification_preference;
93
94
    /**
95
     * @var string response from moip API.
96
     */
97
    protected $body_moip_account_create;
98
99
    /**
100
     * @var string response from moip API.
101
     */
102
    protected $body_moip_account_get;
103
104
    /**
105
     * @var string response from moip API.
106
     */
107
    protected $body_order_list;
108
109
    /**
110
     * @var string response from moip API.
111
     */
112
    protected $body_notification_list;
113
114
    /**
115
     * @var string response from moip API.
116
     */
117
    protected $body_transfers_create;
118
119
    /**
120
     * @var string response from moip API.
121
     */
122
    protected $body_transfers_list;
123
124
    /**
125
     * @var string response from moip API.
126
     */
127
    protected $body_transfers_revert;
128
129
    /**
130
     * @var string response from moip API.
131
     */
132
    protected $body_bank_account_create;
133
134
    /**
135
     * @var string response from moip API.
136
     */
137
    protected $body_bank_account_list;
138
139
    /**
140
     * @var string response from moip API.
141
     */
142
    protected $body_bank_account_update;
143
144
    /**
145
     * @var string response from moip API.
146
     */
147
    protected $body_balances;
148
149
    /**
150
     * @var string holds the last generated customer ownId. In mock mode it'll be always the default, but it changes on sandbox mode.
151
     */
152
    protected $last_cus_id = 'meu_id_customer';
153
154
    /**
155
     * @var string same as `$last_cus_id` but for orders.
156
     *
157
     * @see $last_cus_id
158
     */
159
    protected $last_ord_id = 'meu_id_pedido';
160
    protected $sandbox_mock = self::MOCK;
161
162
    public function __construct()
163
    {
164
        parent::__construct();
165
166
        $this->body_client = $this->readJsonFile('jsons/customer/create');
167
168
        $this->body_order = $this->readJsonFile('jsons/order/create');
169
170
        $this->body_cc_pay_pci = $this->readJsonFile('jsons/payment/create_cc_pci');
171
172
        $this->body_cc_pay_pci_store = $this->readJsonFile('jsons/payment/create_cc_pci_store');
173
174
        $this->body_cc_pay_pci_escrow = $this->readJsonFile('jsons/payment/create_cc_pci_escrow');
175
176
        $this->body_release_escrow = $this->readJsonFile('jsons/escrow/release');
177
178
        $this->body_billet_pay = $this->readJsonFile('jsons/payment/create_billet');
179
180
        $this->body_billet_multipay = $this->readJsonFile('jsons/multipayment/create_billet');
0 ignored issues
show
The property body_billet_multipay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
181
182
        $this->body_refund_full_bankaccount = $this->readJsonFile('jsons/refund/full_bankaccount');
183
184
        $this->body_cc_multipay = $this->readJsonFile('jsons/multipayment/create_cc');
0 ignored issues
show
The property body_cc_multipay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
185
186
        $this->body_notification_preference = $this->readJsonFile('jsons/notification/create');
187
188
        $this->body_moip_account_create = $this->readJsonFile('jsons/account/create');
189
190
        $this->body_moip_account_get = $this->readJsonFile('jsons/account/get');
191
192
        $this->body_order_list = $this->readJsonFile('jsons/order/get_list');
193
194
        $this->body_add_credit_card = $this->readJsonFile('jsons/customer/add_credit_card');
0 ignored issues
show
The property body_add_credit_card does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
195
196
        $this->body_list_webhook_no_filter = $this->readJsonFile('jsons/webhooks/get_no_filter');
0 ignored issues
show
The property body_list_webhook_no_filter does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
197
198
        $this->body_list_webhook_pagination = $this->readJsonFile('jsons/webhooks/get_pagination');
0 ignored issues
show
The property body_list_webhook_pagination does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
199
200
        $this->body_list_webhook_all_filters = $this->readJsonFile('jsons/webhooks/get_all_filters');
0 ignored issues
show
The property body_list_webhook_all_filters does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
201
202
        $this->body_notification_list = $this->readJsonFile('jsons/notification/list');
203
204
        $this->body_multiorder = $this->readJsonFile('jsons/multiorder/create');
0 ignored issues
show
The property body_multiorder does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
205
206
        $this->body_cc_delay_capture = $this->readJsonFile('jsons/payment/create_cc_delay_capture');
0 ignored issues
show
The property body_cc_delay_capture does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
207
208
        $this->body_capture_pay = $this->readJsonFile('jsons/payment/capture');
0 ignored issues
show
The property body_capture_pay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
209
210
        $this->body_capture_multipay = $this->readJsonFile('jsons/multipayment/capture');
0 ignored issues
show
The property body_capture_multipay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
211
212
        $this->body_cancel_pay = $this->readJsonFile('jsons/payment/cancel_pre_authorized');
0 ignored issues
show
The property body_cancel_pay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
213
214
        $this->body_cancel_multipay = $this->readJsonFile('jsons/multipayment/cancel_pre_authorized');
0 ignored issues
show
The property body_cancel_multipay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
215
216
        $this->body_get_pay = $this->readJsonFile('jsons/payment/get');
0 ignored issues
show
The property body_get_pay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
217
218
        $this->body_get_multipay = $this->readJsonFile('jsons/multipayment/get');
0 ignored issues
show
The property body_get_multipay does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
219
220
        $this->body_keys = $this->readJsonFile('jsons/keys/get');
0 ignored issues
show
The property body_keys does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
221
222
        $this->body_transfers_create = $this->readJsonFile('jsons/transfers/create');
223
224
        $this->body_transfers_list = $this->readJsonFile('jsons/transfers/list');
225
226
        $this->body_transfers_revert = $this->readJsonFile('jsons/transfers/revert');
227
228
        $this->body_keys = $this->readJsonFile('jsons/keys/get');
229
230
        $this->body_order_refund_full_bankaccount = $this->readJsonFile('jsons/refund/order_full_bankaccount');
0 ignored issues
show
The property body_order_refund_full_bankaccount does not seem to exist. Did you mean body_order?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
231
232
        $this->body_payment_refund_full_bankaccount = $this->readJsonFile('jsons/refund/payment_full_bankaccount');
0 ignored issues
show
The property body_payment_refund_full_bankaccount does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
233
234
        $this->body_order_refund_partial_bankaccount = $this->readJsonFile('jsons/refund/order_partial_bankaccount');
0 ignored issues
show
The property body_order_refund_partial_bankaccount does not seem to exist. Did you mean body_order?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
235
236
        $this->body_payment_refund_partial_bankaccount = $this->readJsonFile('jsons/refund/payment_partial_bankaccount');
0 ignored issues
show
The property body_payment_refund_partial_bankaccount does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
237
238
        $this->body_order_refund_full_cc = $this->readJsonFile('jsons/refund/order_full_cc');
0 ignored issues
show
The property body_order_refund_full_cc does not seem to exist. Did you mean body_order?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
239
240
        $this->body_payment_refund_full_cc = $this->readJsonFile('jsons/refund/payment_full_cc');
0 ignored issues
show
The property body_payment_refund_full_cc does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
241
242
        $this->body_order_refund_partial_cc = $this->readJsonFile('jsons/refund/order_partial_cc');
0 ignored issues
show
The property body_order_refund_partial_cc does not seem to exist. Did you mean body_order?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
243
244
        $this->body_payment_refund_partial_cc = $this->readJsonFile('jsons/refund/payment_partial_cc');
0 ignored issues
show
The property body_payment_refund_partial_cc does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
245
246
        $this->body_bank_account_create = $this->readJsonFile('jsons/bank_account/create');
247
248
        $this->body_bank_account_list = $this->readJsonFile('jsons/bank_account/list');
249
250
        $this->body_bank_account_update = $this->readJsonFile('jsons/bank_account/update');
251
252
        $this->body_balances = $this->readJsonFile('jsons/balances/get');
253
    }
254
255
    /**
256
     * Sets up the fixture, for example, open a network connection.
257
     * This method is called before a test is executed.
258
     */
259
    public function setUp()
260
    {
261
        // check if we can run the request on sandbox
262
        $moip_access_token = getenv('MOIP_ACCESS_TOKEN');
263
264
        if ($moip_access_token) {
265
            $this->sandbox_mock = self::SANDBOX;
266
            $auth = new OAuth($moip_access_token);
267
        } else {
268
            $this->sandbox_mock = self::MOCK;
269
            $auth = $this->getMockBuilder('\Moip\Contracts\Authentication')->getMock();
270
        }
271
        $this->moip = new Moip($auth, Moip::ENDPOINT_SANDBOX);
272
    }
273
274
    /**
275
     * Method to read JSON from a file.
276
     *
277
     * @param string $filename location of file
278
     */
279
    public function readJsonFile($filename)
280
    {
281
        return file_get_contents($filename.'.json', FILE_USE_INCLUDE_PATH);
282
    }
283
284
    /**
285
     * If in MOCK mode returns a mocked Requests_Sessesion if in SANDBOX mode, creates a new session.
286
     *
287
     * @param string $body        what the request will return
288
     * @param int    $status_code what http code the request will return
289
     */
290
    public function mockHttpSession($body, $status_code = 200)
291
    {
292
        if ($this->sandbox_mock == self::SANDBOX) {
293
            $this->moip->createNewSession();
294
295
            return;
296
        }
297
        $resp = new Requests_Response();
298
        $resp->body = $body;
299
        $resp->status_code = $status_code;
300
        $sess = $this->getMockBuilder('\Requests_Session')->getMock();
301
        $sess->expects($this->once())->method('request')->willReturn($resp);
302
        $this->moip->setSession($sess);
0 ignored issues
show
$sess is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Requests_Session>.

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...
303
    }
304
305
    /**
306
     * Creates a customer.
307
     *
308
     * @return Customer
309
     */
310
    public function createCustomer()
311
    {
312
        if ($this->sandbox_mock == self::SANDBOX) {
313
            $this->last_cus_id = uniqid('CUS-');
314
        } else {
315
            $this->last_cus_id = 'meu_id_sandbox';
316
        }
317
318
        $customer = $this->moip->customers()->setOwnId($this->last_cus_id)
319
            ->setBirthDate(\DateTime::createFromFormat($this->date_format, $this->date_string))
320
            ->setFullname('Jose Silva')
321
            ->setEmail('[email protected]')
322
            ->setTaxDocument('22222222222', 'CPF')
323
            ->setPhone(11, 66778899, 55)
324
            ->addAddress(Customer::ADDRESS_SHIPPING, 'Avenida Faria Lima', '2927', 'Itaim', 'Sao Paulo', 'SP', '01234000', '8');
325
326
        return $customer;
327
    }
328
329
    /**
330
     * Creates a holder.
331
     *
332
     * @return Holder
333
     */
334
    public function createHolder()
335
    {
336
        $holder = $this->moip->holders()->setFullname('Jose Silva')
337
            ->setBirthDate(\DateTime::createFromFormat($this->date_format, $this->date_string))
0 ignored issues
show
It seems like \DateTime::createFromFor...at, $this->date_string) targeting DateTime::createFromFormat() can also be of type false; however, Moip\Resource\Holder::setBirthDate() does only seem to accept object<DateTime>|string, did you maybe forget to handle an error condition?
Loading history...
338
            ->setTaxDocument('22222222222', 'CPF')
339
            ->setPhone(11, 66778899, 55)
340
            ->setAddress(Holder::ADDRESS_BILLING, 'Avenida Faria Lima', '2927', 'Itaim', 'Sao Paulo', 'SP', '01234000', '8');
341
342
        return $holder;
343
    }
344
345
    /**
346
     * Creates a account.
347
     *
348
     * @return Account
349
     */
350
    public function createAccount()
351
    {
352
        $moip = new Moip(new OAuth('1tldio91gi74r34zv30d4saz8yuuws5'), Moip::ENDPOINT_SANDBOX);
353
354
        $uniqEmail = 'fulano'.uniqid('MPA-').'@detal123.com.br';
355
356
        $account = $moip->accounts()
357
            ->setEmail($uniqEmail)
358
            ->setName('Fulano')
359
            ->setLastName('de Tal')
360
            ->setBirthDate('1987-11-27')
361
            ->setTaxDocument('22222222222')
362
            ->setPhone(11, 988888888)
363
            ->addAddress('Av. Ibirapuera', '2035', 'Moema', 'Sao Paulo', 'SP', '04078010')
364
            ->setIdentityDocument('411111115', 'SSP', '2000-05-06')
365
            ->create();
366
367
        return $account;
368
    }
369
370
    /**
371
     * Creates an order.
372
     *
373
     * @return Orders
374
     */
375
    public function createOrder()
376
    {
377 View Code Duplication
        if ($this->sandbox_mock == self::SANDBOX) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
378
            $this->last_ord_id = uniqid('ORD-');
379
        } else {
380
            $this->last_ord_id = 'meu_id_pedido';
381
        }
382
383
        $order = $this->moip->orders()->setCustomer($this->createCustomer())
384
            ->addItem('Nome do produto', 1, 'Mais info...', 100000, 'SHOES')
385
            ->addItem('abacaxi', 2, 'Abacaxi de terra de areia', 990, 'OTHER_CATEGORIES')
386
            ->setDiscount(1000)
387
            ->setShippingAmount(1490)
388
            ->setOwnId($this->last_ord_id);
389
390
        return $order;
391
    }
392
393
    /**
394
     * Creates a multiorder.
395
     *
396
     * @return Multiorders
397
     */
398
    public function createMultiorder()
399
    {
400 View Code Duplication
        if ($this->sandbox_mock == self::SANDBOX) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
401
            $this->last_ord_id = uniqid('MOR-');
402
        } else {
403
            $this->last_ord_id = 'meu_id_pedido';
404
        }
405
406
        $order = $this->moip->orders()->setOwnId(uniqid())
407
            ->addItem('bicicleta 1', 1, 'sku1', 10000)
408
            ->addItem('bicicleta 2', 1, 'sku2', 11000)
409
            ->addItem('bicicleta 3', 1, 'sku3', 12000)
410
            ->addItem('bicicleta 4', 1, 'sku4', 13000)
411
            ->setShippingAmount(3000)
412
            ->setAddition(1000)
413
            ->setDiscount(5000)
414
            ->setCustomer($this->createCustomer())
415
            ->addReceiver('MPA-VB5OGTVPCI52', 'PRIMARY', null);
416
417
        $order2 = $this->moip->orders()->setOwnId(uniqid())
418
            ->addItem('bicicleta 1', 1, 'sku1', 10000)
419
            ->addItem('bicicleta 2', 1, 'sku2', 11000)
420
            ->addItem('bicicleta 3', 1, 'sku3', 12000)
421
            ->setShippingAmount(3000)
422
            ->setAddition(1000)
423
            ->setDiscount(5000)
424
            ->setCustomer($this->createCustomer())
425
            ->addReceiver('MPA-IFYRB1HBL73Z', 'PRIMARY', null);
426
427
        $multiorder = $this->moip->multiorders()
428
                ->setOwnId(uniqid())
429
                ->addOrder($order)
430
                ->addOrder($order2);
431
432
        return $multiorder;
433
    }
434
435
    /**
436
     * Tears down the fixture, for example, close a network connection.
437
     * This method is called after a test is executed.
438
     */
439
    public function tearDown()
440
    {
441
        $this->moip = null;
442
    }
443
}
444