ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRandomTest Class Reference
+ Inheritance diagram for ilRandomTest:
+ Collaboration diagram for ilRandomTest:

Public Member Functions

 testConstruct ()
 
 testIntSuccessfully (int ... $arguments)
 intArguments More...
 
 testIntWithInvalidArguments ()
 
 testLogIfPossible ()
 
 intArguments ()
 

Detailed Description

Definition at line 9 of file ilRandomTest.php.

Member Function Documentation

◆ intArguments()

ilRandomTest::intArguments ( )

Definition at line 60 of file ilRandomTest.php.

60  : array
61  {
62  return [
63  'No arguments can be provided' => [],
64  'One argument can be provided' => [34],
65  '2 arguments can be provided' => [-20, 30],
66  'The limit is inclusive' => [8, 8]
67  ];
68  }

◆ testConstruct()

ilRandomTest::testConstruct ( )

Definition at line 11 of file ilRandomTest.php.

11  : void
12  {
13  $this->assertInstanceOf(\ilRandom::class, new ilRandom());
14  }
Wrapper for generation of random numbers, strings, bytes.

◆ testIntSuccessfully()

ilRandomTest::testIntSuccessfully ( int ...  $arguments)

intArguments

Definition at line 19 of file ilRandomTest.php.

References Vendor\Package\$e.

19  : void
20  {
21  $this->expectNotToPerformAssertions();
22 
23  $random = new \ilRandom();
24  try {
25  $random->int(...$arguments);
26  } catch (Error $e) {
27  $this->fail('Expected no exception.');
28  }
29  }

◆ testIntWithInvalidArguments()

ilRandomTest::testIntWithInvalidArguments ( )

Definition at line 31 of file ilRandomTest.php.

31  : void
32  {
33  $this->expectException(Error::class);
34  $random = new \ilRandom();
35 
36  $random->int(10, 9);
37  }

◆ testLogIfPossible()

ilRandomTest::testLogIfPossible ( )

Definition at line 39 of file ilRandomTest.php.

References $factory, $GLOBALS, and ilLogLevel\ERROR.

39  : void
40  {
41  $this->expectException(Error::class);
42 
43  $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
44  $logger->expects(self::once())->method('logStack')->with(\ilLogLevel::ERROR);
45  $logger->expects(self::once())->method('error');
46 
47  $factory = $this->getMockBuilder(ilLoggerFactory::class)->disableOriginalConstructor()->getMock();
48  $factory->expects(self::once())->method('getComponentLogger')->with('rnd')->willReturn($logger);
49 
50  $GLOBALS['DIC'] = new Container();
51  $GLOBALS['DIC']['ilLoggerFactory'] = static function () use ($factory): ilLoggerFactory {
52  return $factory;
53  };
54  $random = new \ilRandom();
55  $random->int(10, 9);
56 
57  unset($GLOBALS['DIC']);
58  }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$factory
Definition: metadata.php:75

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