Skip to content

Commit

Permalink
Merge branch '3.8' into 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Jun 25, 2019
2 parents 6149954 + 8bd7201 commit f7dcd4a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 60 deletions.
4 changes: 1 addition & 3 deletions tests/Auth/Feature/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Orchestra\Auth\TestCase\Feature;

use Orchestra\Testbench\TestCase as Testbench;
use Illuminate\Auth\AuthServiceProvider as BaseServiceProvider;
use Orchestra\Auth\AuthServiceProvider as OverrideServiceProvider;

abstract class TestCase extends Testbench
{
Expand All @@ -28,7 +26,7 @@ protected function setUp(): void
protected function overrideApplicationProviders($app): array
{
return [
BaseServiceProvider::class => OverrideServiceProvider::class,
'Illuminate\Auth\AuthServiceProvider' => 'Orchestra\Auth\AuthServiceProvider',
];
}
}
57 changes: 0 additions & 57 deletions tests/Auth/Unit/SessionGuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,61 +368,4 @@ public function testIsNotAnyMethodWhenInvalidRolesIsReturned()
$this->assertTrue($stub->isNotAny(['admin', 'editor']));
$this->assertTrue($stub->isNotAny(['admin', 'user']));
}

/**
* Test Orchestra\Support\Auth::logout() method.
*
* @test
*/
public function testLogoutMethod()
{
$cookie = m::mock('\Illuminate\Contracts\Cookie\QueueingFactory');

$events = $this->events;
$provider = $this->provider;
$session = $this->session;
$request = $this->request;

$request->cookies = $cookie;

$events->shouldReceive('until')->never()
->with('orchestra.auth: roles', m::any())->andReturn(['admin', 'editor'])
->shouldReceive('dispatch')->once()
->with(m::type('\Illuminate\Auth\Events\Logout'))->andReturnNull();
$provider->shouldReceive('updateRememberToken')->once();
$session->shouldReceive('remove')->once()->andReturnNull();

$stub = new SessionGuard('web', $provider, $session);
$stub->setDispatcher($events);
$stub->setCookieJar($cookie);
$stub->setRequest($request);

$key = 'remember_web_'.sha1(get_class($stub));

$cookie->shouldReceive('get')->once()->andReturn($key)
->shouldReceive('queue')->once()->andReturn($cookie)
->shouldReceive('forget')->once()->with($key)->andReturnNull();

$refl = new \ReflectionObject($stub);
$user = $refl->getProperty('user');
$userRoles = $refl->getProperty('userRoles');

$user->setAccessible(true);
$userRoles->setAccessible(true);

$userStub = m::mock('\Illuminate\Contracts\Auth\Authenticatable');

$userStub->shouldReceive('getAuthIdentifier')->once()->andReturn(1)
->shouldReceive('getRememberToken')->once()->andReturn('qwerty')
->shouldReceive('setRememberToken')->once()->with(M::type('String'));

$user->setValue($stub, $userStub);
$userRoles->setValue($stub, [1 => new Collection(['admin', 'editor'])]);

$this->assertEquals(new Collection(['admin', 'editor']), $stub->roles());

$stub->logout();

$this->assertSame([], $userRoles->getValue($stub));
}
}

0 comments on commit f7dcd4a

Please sign in to comment.