blob: bb4f7e92ca3a38e64ec6bd5a2e78acf8bbec6804 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?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()
{
/** @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) {
$paths = $callable();
$this->assertTrue(is_array($paths));
$this->assertTrue(in_array('/metrics', $paths));
});
$serviceProvider = new SessionHandlerServiceProvider($app);
$serviceProvider->register();
}
}
|