Skip to content

Commit 5384384

Browse files
committed
Merge branch 'release/1.2.8'
2 parents ce85540 + cd896de commit 5384384

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838

3939
- name: PHP Security Checker
4040
uses: symfonycorp/security-checker-action@v2
41+
with:
42+
disable-exit-code: 1
4143
if: ${{ matrix.stability == 'prefer-stable' }}
4244

4345
- name: Execute tests

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.7
1+
1.2.8

src/Http/Controllers/ClickUpController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Spinen\ClickUp\Http\Controllers;
44

5-
use App\User;
65
use GuzzleHttp\Exception\GuzzleException;
6+
use Illuminate\Foundation\Auth\User;
77
use Illuminate\Http\RedirectResponse;
88
use Illuminate\Http\Request;
99
use Illuminate\Routing\Controller;

tests/Http/Controllers/ClickUpControllerTest.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Spinen\ClickUp\Http\Controllers;
44

5+
use Illuminate\Foundation\Auth\User;
56
use Illuminate\Http\RedirectResponse;
67
use Illuminate\Http\Request;
78
use Illuminate\Routing\Redirector;
@@ -45,7 +46,7 @@ protected function setUp(): void
4546

4647
$this->request_mock = Mockery::mock(Request::class);
4748

48-
$this->user_mock = Mockery::mock('App\User');
49+
$this->user_mock = Mockery::mock(User::class);
4950

5051
$this->controller = new ClickUpController();
5152
}
@@ -110,6 +111,16 @@ public function it_saves_the_users_clickup_token_to_the_oauth_token()
110111
->withNoArgs()
111112
->andReturnTrue();
112113

114+
$this->user_mock->shouldReceive('setAttribute')
115+
->with('clickup_token', 'oauth_token')
116+
->once()
117+
->andReturn($this->user_mock);
118+
119+
$this->user_mock->shouldReceive('getAttribute')
120+
->with('clickup_token')
121+
->once()
122+
->andReturn('oauth_token');
123+
113124
$this->redirector_mock->shouldIgnoreMissing();
114125

115126
$this->controller->processCode(

tests/Http/Middleware/FilterTest.php

+24-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Spinen\ClickUp\Http\Middleware;
44

55
use Illuminate\Contracts\Routing\UrlGenerator;
6+
use Illuminate\Foundation\Auth\User;
67
use Illuminate\Http\RedirectResponse;
78
use Illuminate\Http\Request;
89
use Illuminate\Routing\Redirector;
@@ -63,7 +64,7 @@ protected function setUp(): void
6364
$this->request_mock = Mockery::mock(Request::class);
6465
$this->response_mock = Mockery::mock(RedirectResponse::class);
6566
$this->url_generator_mock = Mockery::mock(UrlGenerator::class);
66-
$this->user_mock = Mockery::mock('App\User');
67+
$this->user_mock = Mockery::mock(User::class);
6768

6869
$this->request_mock->shouldReceive('user')
6970
->withNoArgs()
@@ -89,6 +90,7 @@ public function it_calls_next_middleware_if_user_has_a_clickup_token()
8990
$this->assertEquals($this->request_mock, $request);
9091
};
9192

93+
$this->mockUserAttributeMutators('token');
9294
$this->user_mock->clickup_token = 'token';
9395

9496
$this->filter->handle($this->request_mock, $next_middleware);
@@ -104,6 +106,7 @@ public function it_does_not_call_next_middleware_if_user_does_not_have_a_clickup
104106
$this->assertTrue(false);
105107
};
106108

109+
$this->mockUserAttributeMutators();
107110
$this->user_mock->clickup_token = null;
108111

109112
$this->clickup_mock->shouldIgnoreMissing();
@@ -127,6 +130,7 @@ public function it_sets_intended_url_when_user_does_not_have_a_clickup_token()
127130
$this->assertTrue(false);
128131
};
129132

133+
$this->mockUserAttributeMutators();
130134
$this->user_mock->clickup_token = null;
131135

132136
$this->clickup_mock->shouldIgnoreMissing();
@@ -162,6 +166,7 @@ public function it_redirects_user_to_correct_uri_if_it_does_not_have_a_clickup_t
162166
$this->assertTrue(false);
163167
};
164168

169+
$this->mockUserAttributeMutators();
165170
$this->user_mock->clickup_token = null;
166171

167172
// $this->clickup_mock->shouldIgnoreMissing();
@@ -202,4 +207,22 @@ public function it_redirects_user_to_correct_uri_if_it_does_not_have_a_clickup_t
202207

203208
$this->filter->handle($this->request_mock, $next_middleware);
204209
}
210+
211+
/**
212+
* Mock out the models setAttribute and getAttribute mutators with the given token
213+
*
214+
* @param string|null $token
215+
*/
216+
protected function mockUserAttributeMutators($token = null): void
217+
{
218+
$this->user_mock->shouldReceive('setAttribute')
219+
->with('clickup_token', $token)
220+
->once()
221+
->andReturn($this->user_mock);
222+
223+
$this->user_mock->shouldReceive('getAttribute')
224+
->with('clickup_token')
225+
->once()
226+
->andReturn($token);
227+
}
205228
}

0 commit comments

Comments
 (0)