Skip to content

Commit

Permalink
Merge branch 'release/1.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
ssfinney committed May 25, 2021
2 parents ce85540 + cd896de commit 5384384
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:

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

- name: Execute tests
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.7
1.2.8
2 changes: 1 addition & 1 deletion src/Http/Controllers/ClickUpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Spinen\ClickUp\Http\Controllers;

use App\User;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Foundation\Auth\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand Down
13 changes: 12 additions & 1 deletion tests/Http/Controllers/ClickUpControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Spinen\ClickUp\Http\Controllers;

use Illuminate\Foundation\Auth\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
Expand Down Expand Up @@ -45,7 +46,7 @@ protected function setUp(): void

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

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

$this->controller = new ClickUpController();
}
Expand Down Expand Up @@ -110,6 +111,16 @@ public function it_saves_the_users_clickup_token_to_the_oauth_token()
->withNoArgs()
->andReturnTrue();

$this->user_mock->shouldReceive('setAttribute')
->with('clickup_token', 'oauth_token')
->once()
->andReturn($this->user_mock);

$this->user_mock->shouldReceive('getAttribute')
->with('clickup_token')
->once()
->andReturn('oauth_token');

$this->redirector_mock->shouldIgnoreMissing();

$this->controller->processCode(
Expand Down
25 changes: 24 additions & 1 deletion tests/Http/Middleware/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spinen\ClickUp\Http\Middleware;

use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Foundation\Auth\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
Expand Down Expand Up @@ -63,7 +64,7 @@ protected function setUp(): void
$this->request_mock = Mockery::mock(Request::class);
$this->response_mock = Mockery::mock(RedirectResponse::class);
$this->url_generator_mock = Mockery::mock(UrlGenerator::class);
$this->user_mock = Mockery::mock('App\User');
$this->user_mock = Mockery::mock(User::class);

$this->request_mock->shouldReceive('user')
->withNoArgs()
Expand All @@ -89,6 +90,7 @@ public function it_calls_next_middleware_if_user_has_a_clickup_token()
$this->assertEquals($this->request_mock, $request);
};

$this->mockUserAttributeMutators('token');
$this->user_mock->clickup_token = 'token';

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

$this->mockUserAttributeMutators();
$this->user_mock->clickup_token = null;

$this->clickup_mock->shouldIgnoreMissing();
Expand All @@ -127,6 +130,7 @@ public function it_sets_intended_url_when_user_does_not_have_a_clickup_token()
$this->assertTrue(false);
};

$this->mockUserAttributeMutators();
$this->user_mock->clickup_token = null;

$this->clickup_mock->shouldIgnoreMissing();
Expand Down Expand Up @@ -162,6 +166,7 @@ public function it_redirects_user_to_correct_uri_if_it_does_not_have_a_clickup_t
$this->assertTrue(false);
};

$this->mockUserAttributeMutators();
$this->user_mock->clickup_token = null;

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

$this->filter->handle($this->request_mock, $next_middleware);
}

/**
* Mock out the models setAttribute and getAttribute mutators with the given token
*
* @param string|null $token
*/
protected function mockUserAttributeMutators($token = null): void
{
$this->user_mock->shouldReceive('setAttribute')
->with('clickup_token', $token)
->once()
->andReturn($this->user_mock);

$this->user_mock->shouldReceive('getAttribute')
->with('clickup_token')
->once()
->andReturn($token);
}
}

0 comments on commit 5384384

Please sign in to comment.