ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ProvideWithdrawalTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\LegalDocuments\test\ContainerMock;
24use PHPUnit\Framework\TestCase;
26use ilCtrl;
28use ilSession;
29
30require_once __DIR__ . '/../ContainerMock.php';
31
32class ProvideWithdrawalTest extends TestCase
33{
34 use ContainerMock;
35
36 public function testConstruct(): void
37 {
38 $this->assertInstanceOf(ProvideWithdrawal::class, new ProvideWithdrawal(
39 'foo',
40 $this->mock(ilCtrl::class),
41 $this->mock(ilAuthSession::class)
42 ));
43 }
44
45 public function testBeginProcessURL(): void
46 {
47 $instance = new ProvideWithdrawal(
48 'foo',
49 $this->mock(ilCtrl::class),
50 $this->mock(ilAuthSession::class),
51 function (array $params): string {
52 $this->assertSame(['withdraw_consent' => 'foo'], $params);
53 return 'logout url';
54 }
55 );
56
57 $this->assertSame('logout url', $instance->beginProcessURL());
58 }
59
60 public function testFinishAndLogout(): void
61 {
62 $called = false;
63
64 $auth_session = $this->mock(ilAuthSession::class);
65 $auth_session->expects(self::once())->method('logout');
66
67 $ctrl = $this->mock(ilCtrl::class);
68 $ctrl->expects(self::once())->method('redirectToURL')->with('login.php?bar=baz&withdrawal_finished=foo&cmd=force_login');
69
70 $instance = new ProvideWithdrawal(
71 'foo',
72 $ctrl,
73 $auth_session,
74 $this->fail(...),
75 function (int $x) use (&$called) {
76 $this->assertSame(ilSession::SESSION_CLOSE_USER, $x);
77 $called = true;
78 }
79 );
80
81 $instance->finishAndLogout(['bar' => 'baz']);
82
83 $this->assertTrue($called);
84 }
85}
finishAndLogout(array $additional_url_parameters=[])
Class ilCtrl provides processing control methods.
const int SESSION_CLOSE_USER
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31