Completed
Push — master ( 0f907a...866d23 )
by Andrii
02:30
created

tests/unit/Message/PurchaseRequestTest.php (3 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
/*
4
 * PayPal driver for Omnipay PHP payment library
5
 *
6
 * @link      https://github.com/hiqdev/omnipay-paypal
7
 * @package   omnipay-paypal
8
 * @license   MIT
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace Omnipay\PayPal\Message;
13
14
use Omnipay\Tests\TestCase;
15
16
class PurchaseRequestTest extends TestCase
17
{
18
    private $request;
19
20
    private $purse          = '[email protected]';
21
    private $secret         = '22SAD#-78G888';
22
    private $returnUrl      = 'https://www.foodstore.com/success';
23
    private $cancelUrl      = 'https://www.foodstore.com/failure';
24
    private $notifyUrl      = 'https://www.foodstore.com/notify';
25
    private $description    = 'Test Transaction long description';
26
    private $transactionId  = '12345ASD67890sd';
27
    private $sum            = '1.65';
28
    private $amount         = '14.65';
29
    private $quantity       = '1';
0 ignored issues
show
The property $quantity is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
30
    private $currency       = 'USD';
31
    private $testMode       = true;
32
33 View Code Duplication
    public function setUp()
0 ignored issues
show
This method seems to be duplicated in 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...
34
    {
35
        parent::setUp();
36
37
        $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
38
        $this->request->initialize([
39
            'purse'         => $this->purse,
40
            'secret'        => $this->secret,
41
            'returnUrl'     => $this->returnUrl,
42
            'cancelUrl'     => $this->cancelUrl,
43
            'notifyUrl'     => $this->notifyUrl,
44
            'description'   => $this->description,
45
            'transactionId' => $this->transactionId,
46
            'sum'           => $this->sum,
47
            'amount'        => $this->amount,
48
            'currency'      => $this->currency,
49
            'testMode'      => $this->testMode,
50
        ]);
51
    }
52
53 View Code Duplication
    public function testGetData()
0 ignored issues
show
This method seems to be duplicated in 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...
54
    {
55
        $data = $this->request->getData();
56
57
        $this->assertSame($this->purse,         $data['business']);
58
        $this->assertSame($this->returnUrl,     $data['return']);
59
        $this->assertSame($this->cancelUrl,     $data['cancel_return']);
60
        $this->assertSame($this->notifyUrl,     $data['notify_url']);
61
        $this->assertSame($this->description,   $data['item_name']);
62
        $this->assertSame($this->transactionId, $data['item_number']);
63
        $this->assertSame($this->sum,           $data['amount']);
64
    }
65
66
    public function testSendData()
67
    {
68
        $data = $this->request->getData();
69
        $response = $this->request->sendData($data);
70
        $this->assertSame('Omnipay\PayPal\Message\PurchaseResponse', get_class($response));
71
    }
72
}
73