19 declare(strict_types=1);
35 require_once __DIR__ .
'/ContainerMock.php';
43 $this->assertInstanceOf(Provide::class,
new Provide(
'foo', $this->mock(Internal::class), $this->mock(Container::class)));
48 $container = $this->mockTree(Container::class, [
'ctrl' => $this->mock(ilCtrl::class)]);
49 $container->expects(self::once())->method(
'offsetGet')->with(
'ilAuthSession')->willReturn($this->mock(ilAuthSession::class));
51 $instance =
new Provide(
'foo', $this->mockMethod(Internal::class,
'get', [
'withdraw'],
'foo'),
$container);
53 $this->assertInstanceOf(ProvideWithdrawal::class, $instance->withdrawal());
58 $container = $this->mockTree(Container::class, [
'ctrl' => $this->mock(ilCtrl::class)]);
60 $this->assertInstanceOf(ProvidePublicPage::class, (
new Provide(
'foo', $this->mockMethod(
63 [
'public-page',
'foo'],
70 $document = $this->mock(ProvideDocument::class);
71 $internal = $this->mockMethod(Internal::class,
'get', [
'document',
'foo'], $document);
73 $instance =
new Provide(
'foo', $internal, $this->mock(Container::class));
74 $this->assertSame($document, $instance->document());
79 $history = $this->mock(ProvideHistory::class);
80 $internal = $this->mockMethod(Internal::class,
'get', [
'history',
'foo'], $history);
82 $instance =
new Provide(
'foo', $internal, $this->mock(Container::class));
83 $this->assertSame($history, $instance->history());
88 $document = $this->mock(ProvideDocument::class);
90 $internal = $this->mock(Internal::class);
93 [
'writable-document',
'foo']
96 ->expects(self::exactly(2))
99 function (
$a,
$b) use (&$consecutive, $document) {
100 [$ea, $eb] = array_shift($consecutive);
101 $this->assertEquals($ea,
$a);
102 $this->assertEquals($eb,
$b);
107 $instance =
new Provide(
'foo', $internal, $this->mock(Container::class));
108 $instance->document();
109 $instance->allowEditing()->document();
114 $public_api = $this->mock(PublicApi::class);
115 $internal = $this->mockMethod(Internal::class,
'get', [
'public-api',
'foo'], $public_api);
117 $instance =
new Provide(
'foo', $internal, $this->mock(Container::class));
119 $this->assertSame($public_api, $instance->publicApi());
124 $this->assertSame(
'foo', (
new Provide(
'foo', $this->mock(Internal::class), $this->mock(Container::class)))->
id());
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples