Completed
Push — master ( fde375...74d6aa )
by Vuong
02:28 queued 35s
created

VerifyFilterTest::testMissingCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @link https://github.com/yiiviet/yii2-payment
4
 * @copyright Copyright (c) 2017 Yii Viet
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
9
namespace yiiviet\tests\unit\payment;
10
11
use yiiviet\payment\VerifyFilter;
12
13
/**
14
 * Lớp VerifyFilterTest
15
 *
16
 * @author Vuong Minh <[email protected]>
17
 * @since 1.0.2
18
 */
19
class VerifyFilterTest extends TestCase
20
{
21
22
    public static function gatewayId(): string
23
    {
24
        return 'VTC';
25
    }
26
27
    /**
28
     * @expectedException \yii\base\InvalidConfigException
29
     * @expectedExceptionMessage `command` property must be set!
30
     */
31
    public function testMissingCommand()
32
    {
33
        return new VerifyFilter([
34
            'gateway' => $this->gateway
35
        ]);
36
    }
37
38
    /**
39
     * @expectedException \yii\base\InvalidConfigException
40
     * @expectedExceptionMessage `gateway` property must be set!
41
     */
42
    public function testMissingGateway()
43
    {
44
        return new VerifyFilter([
45
            'command' => 'IPN'
46
        ]);
47
    }
48
49
    /**
50
     * @expectedException  \yii\web\ForbiddenHttpException
51
     */
52 View Code Duplication
    public function testInvalid()
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...
53
    {
54
        $_POST = [
55
            '_method' => 'POST',
56
            'data' => '100000|VND|0963465816|1|74132',
57
            'signature' => '1d31c0779f47e2bc3bfe40becf1fda0d7e881aeb90d8efb0341e258692cf896aa'
58
        ];
59
60
        return (new VerifyFilter([
61
            'gateway' => $this->gateway,
62
            'command' => 'IPN'
63
        ]))->beforeAction(null);
64
    }
65
66
    /**
67
     * @depends testMissingCommand
68
     * @depends testMissingGateway
69
     * @depends testInvalid
70
     */
71 View Code Duplication
    public function test()
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...
72
    {
73
        $_POST = [
74
            '_method' => 'POST',
75
            'data' => '100000|VND|0963465816|1|74132',
76
            'signature' => '1d31c0779f47e2bc3bfe40becf1fda0d7e881aeb90d8efb0341e258692cf896a'
77
        ];
78
79
        $result = (new VerifyFilter([
80
            'gateway' => $this->gateway,
81
            'command' => 'IPN'
82
        ]))->beforeAction(null);
83
84
        $this->assertTrue($result);
85
    }
86
87
88
89
}
90