GatewayTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 26
c 2
b 0
f 0
dl 0
loc 40
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_purchase_redirect() 0 16 1
A test_purchase_connected_account() 0 20 1
1
<?php
2
3
namespace ByTIC\Payments\Stripe\Tests;
4
5
/**
6
 * Class GatewayTest
7
 * @package ByTIC\Payments\Stripe\Tests
8
 */
9
class GatewayTest extends AbstractTest
10
{
11
    public function test_purchase_redirect()
12
    {
13
        $gateway = new \ByTIC\Payments\Stripe\Gateway();
14
        $gateway->initialize(require TEST_FIXTURE_PATH . '/enviromentParams.php');
15
16
        $parameters = require TEST_FIXTURE_PATH . '/requests/Purchase/baseRequest.php';
17
18
        $parameters['returnUrl'] = 'http://test.com';
19
        $request = $gateway->purchase($parameters);
20
        $response = $request->send();
21
22
        $sessionId = $response->getSessionID();
0 ignored issues
show
Bug introduced by
The method getSessionID() does not exist on Omnipay\Common\Message\ResponseInterface. It seems like you code against a sub-type of Omnipay\Common\Message\ResponseInterface such as ByTIC\Payments\Stripe\Message\PurchaseResponse or Omnipay\Stripe\Message\Response or Omnipay\Stripe\Message\PaymentIntents\Response or ByTIC\Payments\Stripe\Message\PurchaseResponse or Omnipay\Stripe\Message\Response. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        $sessionId = $response->getSessionID();
Loading history...
23
        $content = $response->getViewContent();
0 ignored issues
show
Bug introduced by
The method getViewContent() does not exist on Omnipay\Common\Message\ResponseInterface. It seems like you code against a sub-type of Omnipay\Common\Message\ResponseInterface such as ByTIC\Payments\Stripe\Message\PurchaseResponse or ByTIC\Payments\Stripe\Me...ompletePurchaseResponse or ByTIC\Omnipay\Twispay\Me...ompletePurchaseResponse or ByTIC\Omnipay\Twispay\Message\PurchaseResponse or ByTIC\Omnipay\Payu\Messa...ompletePurchaseResponse or ByTIC\Omnipay\Payu\Message\PurchaseResponse or ByTIC\Omnipay\Paylike\Message\PurchaseResponse or ByTIC\Omnipay\Paylike\Me...ompletePurchaseResponse or ByTIC\Omnipay\Euplatesc\Message\PurchaseResponse or ByTIC\Omnipay\Euplatesc\...ompletePurchaseResponse or ByTIC\Omnipay\Romcard\Message\PurchaseResponse or ByTIC\Omnipay\Romcard\Me...ompletePurchaseResponse or ByTIC\Omnipay\PlatiOnlin...ompletePurchaseResponse or ByTIC\Omnipay\PlatiOnline\Message\PurchaseResponse or ByTIC\Omnipay\Euplatesc\Message\PurchaseResponse or ByTIC\Payments\Stripe\Message\PurchaseResponse or ByTIC\Omnipay\Romcard\Message\PurchaseResponse or ByTIC\Omnipay\PlatiOnline\Message\PurchaseResponse or ByTIC\Omnipay\Twispay\Message\PurchaseResponse or ByTIC\Omnipay\Payu\Message\PurchaseResponse. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        /** @scrutinizer ignore-call */ 
24
        $content = $response->getViewContent();
Loading history...
24
        self::assertContains('stripe.redirectToCheckout({', $content);
25
        self::assertContains('sessionId:', $content);
26
        self::assertContains($sessionId, $content);
27
    }
28
29
    public function test_purchase_connected_account()
30
    {
31
        $gateway = new \ByTIC\Payments\Stripe\Gateway();
32
        $gateway->initialize(require TEST_FIXTURE_PATH . '/enviromentParams.php');
33
34
        $parameters = require TEST_FIXTURE_PATH . '/requests/Purchase/baseRequest.php';
35
        $parameters['returnUrl'] = 'http://test.com';
36
37
        $parameters['application_fee_amount'] = '3.0';
38
        $accountId = getenv('STRIPE_CONNECTED_ID');
39
        $parameters['on_behalf_of'] = $accountId;
40
41
        $request = $gateway->purchase($parameters);
42
        $response = $request->send();
43
44
        $sessionId = $response->getSessionID();
45
        $content = $response->getViewContent();
46
        self::assertContains('stripe.redirectToCheckout({', $content);
47
        self::assertContains('sessionId:', $content);
48
        self::assertContains($sessionId, $content);
49
    }
50
}
51