ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAdvancedMDRecordObjectOrderingsTest Class Reference
+ Inheritance diagram for ilAdvancedMDRecordObjectOrderingsTest:
+ Collaboration diagram for ilAdvancedMDRecordObjectOrderingsTest:

Public Member Functions

 testConstruct ()
 
 testGlobalRecordSorting ()
 

Protected Member Functions

 setUp ()
 
 setGlobalVariable (string $name, $value)
 
 initRecordSortingDependencies ()
 

Protected Attributes

Container $dic
 

Detailed Description

Definition at line 22 of file ilAdvancedMDRecordObjectOrderingsTest.php.

Member Function Documentation

◆ initRecordSortingDependencies()

ilAdvancedMDRecordObjectOrderingsTest::initRecordSortingDependencies ( )
protected

Definition at line 78 of file ilAdvancedMDRecordObjectOrderingsTest.php.

78 : void
79 {
80 $this->dic = new Container();
81 $GLOBALS['DIC'] = $this->dic;
82 $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
83 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
$GLOBALS["DIC"]
Definition: wac.php:54

References $dic, $GLOBALS, and setGlobalVariable().

Referenced by setUp().

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

◆ setGlobalVariable()

ilAdvancedMDRecordObjectOrderingsTest::setGlobalVariable ( string  $name,
  $value 
)
protected
Parameters
string$name
mixed$value

Definition at line 67 of file ilAdvancedMDRecordObjectOrderingsTest.php.

67 : void
68 {
69 global $DIC;
70
71 $GLOBALS[$name] = $value;
72 unset($DIC[$name]);
73 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
74 return $value;
75 };
76 }
$c
Definition: deliver.php:25
global $DIC
Definition: shib_login.php:26

References $c, $DIC, and $GLOBALS.

Referenced by initRecordSortingDependencies().

+ Here is the caller graph for this function:

◆ setUp()

ilAdvancedMDRecordObjectOrderingsTest::setUp ( )
protected

Definition at line 26 of file ilAdvancedMDRecordObjectOrderingsTest.php.

26 : void
27 {
29 parent::setUp();
30 }

References initRecordSortingDependencies().

+ Here is the call graph for this function:

◆ testConstruct()

ilAdvancedMDRecordObjectOrderingsTest::testConstruct ( )

Definition at line 32 of file ilAdvancedMDRecordObjectOrderingsTest.php.

32 : void
33 {
34 $sorting = new ilAdvancedMDRecordObjectOrderings();
35 $this->assertTrue($sorting instanceof ilAdvancedMDRecordObjectOrderings);
36 }

◆ testGlobalRecordSorting()

ilAdvancedMDRecordObjectOrderingsTest::testGlobalRecordSorting ( )

Definition at line 38 of file ilAdvancedMDRecordObjectOrderingsTest.php.

38 : void
39 {
40 $record_id_reflection = new ReflectionMethod(ilAdvancedMDRecord::class, 'setRecordId');
41 $record_id_reflection->setAccessible(true);
42
43 $ids = [1, 2, 3, 4, 5];
44 $positions = array_reverse($ids);
45 $records = [];
46 foreach ($ids as $id) {
47 $record = new ilAdvancedMDRecord();
48 $record->setGlobalPosition(array_shift($positions));
49 $record_id_reflection->invokeArgs($record, [$id]);
50
51 $records[] = $record;
52 }
53
54 $sorting = new ilAdvancedMDRecordObjectOrderings();
55 $sorted = $sorting->sortRecords($records);
56 $this->assertTrue(is_array($sorted));
57 foreach ($sorted as $index => $record) {
58 // test reverse ordering (idx + record equals 5)
59 $this->assertEquals(5, $index + $record->getRecordId());
60 }
61 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

Field Documentation

◆ $dic

Container ilAdvancedMDRecordObjectOrderingsTest::$dic
protected

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