ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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 77 of file ilAdvancedMDRecordObjectOrderingsTest.php.

77 : void
78 {
79 $this->dic = new Container();
80 $GLOBALS['DIC'] = $this->dic;
81 $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
82 }
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 66 of file ilAdvancedMDRecordObjectOrderingsTest.php.

66 : void
67 {
68 global $DIC;
69
70 $GLOBALS[$name] = $value;
71 unset($DIC[$name]);
72 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
73 return $value;
74 };
75 }
$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
42 $ids = [1, 2, 3, 4, 5];
43 $positions = array_reverse($ids);
44 $records = [];
45 foreach ($ids as $id) {
46 $record = new ilAdvancedMDRecord();
47 $record->setGlobalPosition(array_shift($positions));
48 $record_id_reflection->invokeArgs($record, [$id]);
49
50 $records[] = $record;
51 }
52
53 $sorting = new ilAdvancedMDRecordObjectOrderings();
54 $sorted = $sorting->sortRecords($records);
55 $this->assertTrue(is_array($sorted));
56 foreach ($sorted as $index => $record) {
57 // test reverse ordering (idx + record equals 5)
58 $this->assertEquals(5, $index + $record->getRecordId());
59 }
60 }
$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: