ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestExceptionTest.php
Go to the documentation of this file.
1 <?php
2 
20 {
24  public function testConstruct(array $input, array $output): void
25  {
26  $ilTestException = isset($input['code'])
27  ? new ilTestException($input['msg'], $input['code'])
28  : new ilTestException($input['msg'])
29  ;
30  $this->assertInstanceOf(ilTestException::class, $ilTestException);
31  $this->assertEquals($output['msg'], $ilTestException->getMessage());
32  $this->assertEquals($output['code'], $ilTestException->getCode());
33  }
34 
35  public static function constructDataProvider(): array
36  {
37  return [
38  [['msg' => '', 'code' => -1], ['msg' => ilTestException::class, 'code' => -1]],
39  [['msg' => '', 'code' => 0], ['msg' => ilTestException::class, 'code' => 0]],
40  [['msg' => '', 'code' => 1], ['msg' => ilTestException::class, 'code' => 1]],
41  [['msg' => ''], ['msg' => ilTestException::class, 'code' => 0]],
42  [['msg' => 'test', 'code' => -1], ['msg' => 'test', 'code' => -1]],
43  [['msg' => 'test', 'code' => 0], ['msg' => 'test', 'code' => 0]],
44  [['msg' => 'test', 'code' => 1], ['msg' => 'test', 'code' => 1]],
45  [['msg' => 'test'], ['msg' => 'test', 'code' => 0]]
46  ];
47  }
48 
52  public function testException(array $input, array $output): void
53  {
54  $this->expectException(ilTestException::class);
55  $this->expectExceptionMessage($output['msg']);
56  $this->expectExceptionCode($output['code']);
57  throw isset($input['code'])
58  ? new ilTestException($input['msg'], $input['code'])
59  : new ilTestException($input['msg'])
60  ;
61  }
62 
63  public static function exceptionDataProvider(): array
64  {
65  return [
66  [['msg' => '', 'code' => -1], ['msg' => ilTestException::class, 'code' => -1]],
67  [['msg' => '', 'code' => 0], ['msg' => ilTestException::class, 'code' => 0]],
68  [['msg' => '', 'code' => 1], ['msg' => ilTestException::class, 'code' => 1]],
69  [['msg' => ''], ['msg' => ilTestException::class, 'code' => 0]],
70  [['msg' => 'test', 'code' => -1], ['msg' => 'test', 'code' => -1]],
71  [['msg' => 'test', 'code' => 0], ['msg' => 'test', 'code' => 0]],
72  [['msg' => 'test', 'code' => 1], ['msg' => 'test', 'code' => 1]],
73  [['msg' => 'test'], ['msg' => 'test', 'code' => 0]]
74  ];
75  }
76 }
testConstruct(array $input, array $output)
constructDataProvider
Base Exception for all Exceptions relating to Modules/Test.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testException(array $input, array $output)
exceptionDataProvider