2018-12-28 03:28:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Middleware;
|
|
|
|
|
|
|
|
use Engelsystem\Middleware\SessionHandler;
|
|
|
|
use Engelsystem\Middleware\SessionHandlerServiceProvider;
|
|
|
|
use Engelsystem\Test\Unit\ServiceProviderTest;
|
|
|
|
use Illuminate\Contracts\Container\ContextualBindingBuilder;
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
|
|
|
|
class SessionHandlerServiceProviderTest extends ServiceProviderTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Middleware\SessionHandlerServiceProvider::register()
|
|
|
|
*/
|
|
|
|
public function testRegister(): void
|
|
|
|
{
|
|
|
|
/** @var ContextualBindingBuilder|MockObject $bindingBuilder */
|
|
|
|
$bindingBuilder = $this->createMock(ContextualBindingBuilder::class);
|
|
|
|
$app = $this->getApp(['when']);
|
|
|
|
|
|
|
|
$app->expects($this->once())
|
|
|
|
->method('when')
|
|
|
|
->with(SessionHandler::class)
|
|
|
|
->willReturn($bindingBuilder);
|
|
|
|
|
|
|
|
$bindingBuilder->expects($this->once())
|
|
|
|
->method('needs')
|
|
|
|
->with('$paths')
|
|
|
|
->willReturn($bindingBuilder);
|
|
|
|
|
|
|
|
$bindingBuilder->expects($this->once())
|
|
|
|
->method('give')
|
|
|
|
->willReturnCallback(function (callable $callable): void {
|
|
|
|
$paths = $callable();
|
|
|
|
|
2019-04-24 10:45:00 +02:00
|
|
|
$this->assertIsArray($paths);
|
2018-12-28 03:28:33 +01:00
|
|
|
$this->assertTrue(in_array('/metrics', $paths));
|
|
|
|
});
|
|
|
|
|
|
|
|
$serviceProvider = new SessionHandlerServiceProvider($app);
|
|
|
|
$serviceProvider->register();
|
|
|
|
}
|
|
|
|
}
|