ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Language\Tests\Activities\FailureTest Class Reference
+ Inheritance diagram for ILIAS\Language\Tests\Activities\FailureTest:
+ Collaboration diagram for ILIAS\Language\Tests\Activities\FailureTest:

Public Member Functions

 testOf4xxExceptionPassesThroughUnchanged (\Exception $e)
 
 testOfMasksEverythingElseAsGeneric500KeepingTheOriginalAsPrevious (\Throwable $defect)
 

Static Public Member Functions

static clientErrorProvider ()
 
static defectProvider ()
 

Static Private Member Functions

static pdoExceptionWithSqlState (string $sql_state)
 PDOException carries its SQLSTATE as string code, which compares numerically against 400..499 in PHP 8. More...
 

Detailed Description

Definition at line 29 of file FailureTest.php.

Member Function Documentation

◆ clientErrorProvider()

static ILIAS\Language\Tests\Activities\FailureTest::clientErrorProvider ( )
static
Returns
array<string, array<int, mixed>>|list<array<int, mixed>>

Definition at line 32 of file FailureTest.php.

32 : array
33 {
34 return [
35 'invalid input (400)' => [new InvalidInputException('bad')],
36 'forbidden (403)' => [new \DomainException('nope', 403)],
37 'ambiguous title (409)' => [new AmbiguousLanguageTitleException('twice')],
38 'lowest 4xx' => [new \RuntimeException('x', 400)],
39 'highest 4xx' => [new \RuntimeException('x', 499)],
40 ];
41 }

◆ defectProvider()

static ILIAS\Language\Tests\Activities\FailureTest::defectProvider ( )
static
Returns
array<string, array<int, mixed>>|list<array<int, mixed>>

Definition at line 50 of file FailureTest.php.

50 : array
51 {
52 return [
53 'code 0' => [new \RuntimeException('SQL: secret', 0)],
54 'below 4xx (399)' => [new \RuntimeException('secret', 399)],
55 'above 4xx (500)' => [new \RuntimeException('secret', 500)],
56 'above 4xx (600)' => [new \RuntimeException('secret', 600)],
57 'Error with 4xx code' => [new \TypeError('secret', 400)],
58 'plain Error' => [new \Error('secret')],
59 'PDOException, SQLSTATE 42S02 as string code' => [self::pdoExceptionWithSqlState('42S02')],
60 'PDOException, SQLSTATE 42S22 as string code' => [self::pdoExceptionWithSqlState('42S22')],
61 ];
62 }
static pdoExceptionWithSqlState(string $sql_state)
PDOException carries its SQLSTATE as string code, which compares numerically against 400....
Definition: FailureTest.php:65

References ILIAS\Language\Tests\Activities\FailureTest\pdoExceptionWithSqlState().

+ Here is the call graph for this function:

◆ pdoExceptionWithSqlState()

static ILIAS\Language\Tests\Activities\FailureTest::pdoExceptionWithSqlState ( string  $sql_state)
staticprivate

PDOException carries its SQLSTATE as string code, which compares numerically against 400..499 in PHP 8.

Definition at line 65 of file FailureTest.php.

65 : \PDOException
66 {
67 return new class ('SQLSTATE: secret table', $sql_state) extends \PDOException {
68 public function __construct(string $message, string $sql_state)
69 {
71 $this->code = $sql_state;
72 }
73 };
74 }
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $message, ILIAS\__construct(), and ILIAS\GlobalScreen\Provider\__construct().

Referenced by ILIAS\Language\Tests\Activities\FailureTest\defectProvider().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testOf4xxExceptionPassesThroughUnchanged()

ILIAS\Language\Tests\Activities\FailureTest::testOf4xxExceptionPassesThroughUnchanged ( \Exception  $e)

Definition at line 44 of file FailureTest.php.

44 : void
45 {
46 $this->assertSame($e, Failure::of($e));
47 }
static of(\Throwable $e)
Definition: Failure.php:29

References Vendor\Package\$e, and ILIAS\Language\Activities\Failure\of().

+ Here is the call graph for this function:

◆ testOfMasksEverythingElseAsGeneric500KeepingTheOriginalAsPrevious()

ILIAS\Language\Tests\Activities\FailureTest::testOfMasksEverythingElseAsGeneric500KeepingTheOriginalAsPrevious ( \Throwable  $defect)

Definition at line 77 of file FailureTest.php.

77 : void
78 {
79 $failure = Failure::of($defect);
80
81 $this->assertNotSame($defect, $failure);
82 $this->assertInstanceOf(\RuntimeException::class, $failure);
83 $this->assertSame(500, $failure->getCode());
84 $this->assertSame('The activity could not be performed.', $failure->getMessage());
85 $this->assertSame($defect, $failure->getPrevious());
86 }

References ILIAS\Language\Activities\Failure\of().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: