2017-11-19 20:34:55 +00:00
|
|
|
<?php
|
|
|
|
|
2018-02-25 21:34:01 +00:00
|
|
|
namespace Tests\Unit\Http\Middleware\API;
|
2017-11-19 20:34:55 +00:00
|
|
|
|
|
|
|
use Mockery as m;
|
|
|
|
use Illuminate\Contracts\Config\Repository;
|
|
|
|
use Tests\Unit\Http\Middleware\MiddlewareTestCase;
|
2018-02-25 21:34:01 +00:00
|
|
|
use Pterodactyl\Http\Middleware\Api\SetSessionDriver;
|
2017-11-19 20:34:55 +00:00
|
|
|
|
|
|
|
class SetSessionDriverTest extends MiddlewareTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Illuminate\Contracts\Config\Repository|\Mockery\Mock
|
|
|
|
*/
|
|
|
|
private $config;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup tests.
|
|
|
|
*/
|
2020-05-09 16:00:52 +00:00
|
|
|
public function setUp(): void
|
2017-11-19 20:34:55 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->config = m::mock(Repository::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that a production environment does not try to disable debug bar.
|
|
|
|
*/
|
2018-07-05 02:38:23 +00:00
|
|
|
public function testMiddleware()
|
2017-11-19 20:34:55 +00:00
|
|
|
{
|
2018-03-10 19:02:49 +00:00
|
|
|
$this->config->shouldReceive('set')->once()->with('session.driver', 'array')->andReturnNull();
|
2017-11-19 20:34:55 +00:00
|
|
|
|
|
|
|
$this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an instance of the middleware with mocked dependencies for testing.
|
|
|
|
*
|
2018-02-25 21:34:01 +00:00
|
|
|
* @return \Pterodactyl\Http\Middleware\Api\SetSessionDriver
|
2017-11-19 20:34:55 +00:00
|
|
|
*/
|
|
|
|
private function getMiddleware(): SetSessionDriver
|
|
|
|
{
|
2018-07-05 02:38:23 +00:00
|
|
|
return new SetSessionDriver($this->config);
|
2017-11-19 20:34:55 +00:00
|
|
|
}
|
|
|
|
}
|