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

47 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2018-02-25 21:34:01 +00:00
namespace Tests\Unit\Http\Middleware\API;
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;
class SetSessionDriverTest extends MiddlewareTestCase
{
/**
* @var \Illuminate\Contracts\Config\Repository|\Mockery\Mock
*/
private $config;
/**
* Setup tests.
*/
public function setUp()
{
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);
}
}