misc_pterodactyl-panel/tests/Unit/Http/Middleware/Api/SetSessionDriverTest.php

47 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Tests\Unit\Http\Middleware\Api;
use Mockery as m;
use Illuminate\Contracts\Config\Repository;
2018-02-25 21:34:01 +00:00
use Pterodactyl\Http\Middleware\Api\SetSessionDriver;
use Pterodactyl\Tests\Unit\Http\Middleware\MiddlewareTestCase;
class SetSessionDriverTest extends MiddlewareTestCase
{
/**
* @var \Illuminate\Contracts\Config\Repository|\Mockery\Mock
*/
private $config;
/**
* Setup tests.
*/
public function setUp(): void
{
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()
{
2018-03-10 19:02:49 +00:00
$this->config->shouldReceive('set')->once()->with('session.driver', 'array')->andReturnNull();
$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
*/
private function getMiddleware(): SetSessionDriver
{
2018-07-05 02:38:23 +00:00
return new SetSessionDriver($this->config);
}
}