Code Duplication    Length = 16-18 lines in 3 locations

tests/JwtServiceTest.php 3 locations

@@ 73-88 (lines=16) @@
70
    /**
71
     * testGetUserIdFromToken method
72
     */
73
    public function testGetUserIdFromToken()
74
    {
75
        $token = $this->getToken();
76
77
        $this->tokenManager->shouldReceive('check')
78
            ->once()
79
            ->with(Mockery::on(function($claim) {
80
                return $claim->sub == 5
81
                    && $claim->iss == 'http://www.test.com';
82
            }))
83
            ->andReturn(true);
84
85
        $userId = $this->jwtService->getUserIdFromToken($token);
86
87
        $this->assertEquals(5, $userId);
88
    }
89
90
    /**
91
     * testGetUserIdFromTokenWithInvalidClaim method
@@ 93-108 (lines=16) @@
90
    /**
91
     * testGetUserIdFromTokenWithInvalidClaim method
92
     */
93
    public function testGetUserIdFromTokenWithInvalidClaim()
94
    {
95
        $token = $this->getToken();
96
97
        $this->tokenManager->shouldReceive('check')
98
            ->once()
99
            ->with(Mockery::on(function($claim) {
100
                return $claim->sub == 5
101
                    && $claim->iss == 'http://www.test.com';
102
            }))
103
            ->andReturn(false);
104
105
        $this->setExpectedException(\WWON\JwtGuard\Exceptions\InvalidTokenException::class);
106
107
        $userId = $this->jwtService->getUserIdFromToken($token);
108
    }
109
110
    /**
111
     * testRefreshToken method
@@ 148-165 (lines=18) @@
145
    /**
146
     * testRefreshUnRefreshableToken method
147
     */
148
    public function testRefreshUnRefreshableToken()
149
    {
150
        $now = Carbon::now()->timestamp;
151
152
        $token = $this->getToken();
153
154
        $this->tokenManager->shouldReceive('check')
155
            ->once()
156
            ->with(Mockery::on(function($claim) {
157
                return $claim->sub == 5
158
                && $claim->iss == 'http://www.test.com';
159
            }))
160
            ->andReturn(true);
161
162
        $this->setExpectedException(\WWON\JwtGuard\Exceptions\UnRefreshableException::class);
163
164
        $newToken = $this->jwtService->refreshToken($token);
165
    }
166
167
    /**
168
     * getToken method