Completed
Push — master ( c310a2...2d8cb6 )
by Kazi Mainuddin
07:28 queued 05:39
created

ProcessorTest::getTransaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 11
loc 11
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Tzsk\Payu\Tests\Helpers;
4
5
use Tzsk\Payu\Tests\TestCase;
6
use Tzsk\Payu\Helpers\Processor;
7
use Illuminate\Support\Facades\Session;
8
use Tzsk\Payu\Model\PayuPayment;
9
use Illuminate\Http\Request;
10
11
class ProcessorTest extends TestCase
12
{
13
    public function testWillReturnPayuPaymentObject()
14
    {
15
        $credentials = $this->getCredentials();
0 ignored issues
show
Unused Code introduced by
$credentials is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
16
        $processor = (new Processor(request()))->process();
17
18
        $this->assertTrue(is_array($processor));
19
    }
20
21 View Code Duplication
    protected function getCredentials($transaction = true)
0 ignored issues
show
Duplication introduced by
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...
22
    {
23
        $data = [
24
            'data' => $transaction ? $this->getTransaction() : [],
25
            'status_url' => 'foo',
26
            'account' => 'payubiz',
27
            'model' => ['id' => 1, 'class' => 'baz'],
28
        ];
29
30
        Session::put('tzsk_payu_data', $data);
31
32
        return $data;
33
    }
34
35 View Code Duplication
    protected function getTransaction()
0 ignored issues
show
Duplication introduced by
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...
36
    {
37
        return [
38
            'txnid' => strtoupper(str_random(8)),
39
            'amount' => rand(100, 999),
40
            'productinfo' => 'Product Information',
41
            'firstname' => 'John',
42
            'email' => '[email protected]',
43
            'phone' => '9876543210',
44
        ];
45
    }
46
}
47