Code Duplication    Length = 31-33 lines in 2 locations

tests/JwtWrapperHashTest.php 2 locations

@@ 37-67 (lines=31) @@
34
    }
35
36
37
    public function testSuccessfulFlow1()
38
    {
39
        $jwt = $this->object->createJwtData($this->dataToToken);
40
41
        $this->assertEquals([
42
            'iat'  => $jwt["iat"],  // Not deterministic for the test
43
            'jti'  => $jwt["jti"],  // Not deterministic for the test
44
            'iss'  => "example.com",
45
            'nbf'  => $jwt["iat"],
46
            'exp'  => $jwt["iat"] + 60,
47
            'data' => $this->dataToToken
48
        ], $jwt);
49
50
        $token = $this->object->generateToken($jwt);
51
52
        $data = $this->object->extractData($token);
53
54
        $expectedData = new stdClass();
55
        $expectedData->iat = $jwt["iat"];  // Not deterministic for the test
56
        $expectedData->jti = $jwt["jti"];  // Not deterministic for the test
57
        $expectedData->iss = "example.com";
58
        $expectedData->nbf = $jwt["iat"];
59
        $expectedData->exp = $jwt["iat"] + 60;
60
        $expectedData->data = (object)$this->dataToToken;
61
62
        $this->assertEquals(
63
            $expectedData,
64
            $data
65
        );
66
67
    }
68
69
    public function testSuccessfulFlow2()
70
    {
@@ 69-101 (lines=33) @@
66
67
    }
68
69
    public function testSuccessfulFlow2()
70
    {
71
        $jwt = $this->object->createJwtData($this->dataToToken);
72
73
        $this->assertEquals([
74
            'iat'  => $jwt["iat"],  // Not deterministic for the test
75
            'jti'  => $jwt["jti"],  // Not deterministic for the test
76
            'iss'  => "example.com",
77
            'nbf'  => $jwt["iat"],
78
            'exp'  => $jwt["iat"] + 60,
79
            'data' => $this->dataToToken
80
        ], $jwt);
81
82
        $token = $this->object->generateToken($jwt);
83
84
        $_SERVER["HTTP_AUTHORIZATION"] = "Bearer $token";
85
86
        $data = $this->object->extractData();
87
88
        $expectedData = new stdClass();
89
        $expectedData->iat = $jwt["iat"];  // Not deterministic for the test
90
        $expectedData->jti = $jwt["jti"];  // Not deterministic for the test
91
        $expectedData->iss = "example.com";
92
        $expectedData->nbf = $jwt["iat"];
93
        $expectedData->exp = $jwt["iat"] + 60;
94
        $expectedData->data = (object)$this->dataToToken;
95
96
        $this->assertEquals(
97
            $expectedData,
98
            $data
99
        );
100
101
    }
102
103
    /**
104
     * @throws \ByJG\Util\JwtWrapperException