ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ProvideWithdrawalTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 use ilCtrl;
27 use ilAuthSession;
28 use ilSession;
29 
30 require_once __DIR__ . '/../ContainerMock.php';
31 
32 class 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 }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
finishAndLogout(array $additional_url_parameters=[])
const SESSION_CLOSE_USER