ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilOrgUnitOperationRegisteredObjectiveTest Class Reference
+ Inheritance diagram for ilOrgUnitOperationRegisteredObjectiveTest:
+ Collaboration diagram for ilOrgUnitOperationRegisteredObjectiveTest:

Public Member Functions

 testIsApplicable ()
 
 testIsApplicableInvalidContextException ()
 
 testAchieve ()
 

Protected Member Functions

 getMockEnviroment (bool $expect_insert, int $expected_context_id=0)
 
 getMockObjective (bool $does_op_already_exist, int $context_id, string $operation_name)
 
 testGetHash ()
 
 testGetPreconditions ()
 

Protected Attributes

int $next_id = 3
 
string $operation = 'first operation'
 
string $description = 'description'
 

Detailed Description

Member Function Documentation

◆ getMockEnviroment()

ilOrgUnitOperationRegisteredObjectiveTest::getMockEnviroment ( bool  $expect_insert,
int  $expected_context_id = 0 
)
protected

Definition at line 30 of file ilOrgUnitOperationRegisteredObjectiveTest.php.

Referenced by testAchieve(), testIsApplicable(), and testIsApplicableInvalidContextException().

33  : Environment {
34  $db = $this->createMock(ilDBInterface::class);
35  if ($expect_insert) {
36  $db
37  ->expects(self::once())
38  ->method('insert')
39  ->with('il_orgu_operations', [
40  'operation_id' => ['integer', $this->next_id],
41  'operation_string' => ['text', $this->operation],
42  'description' => ['text', $this->description],
43  'list_order' => ['integer', 0],
44  'context_id' => ['integer', $expected_context_id],
45  ]);
46  $db
47  ->expects(self::once())
48  ->method('nextId')
49  ->with('il_orgu_operations')
50  ->willReturn($this->next_id);
51  }
52 
53  $env = $this->createMock(Environment::class);
54  $env
55  ->method('getResource')
56  ->with(Environment::RESOURCE_DATABASE)
57  ->willReturn($db);
58 
59  return $env;
60  }
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
+ Here is the caller graph for this function:

◆ getMockObjective()

ilOrgUnitOperationRegisteredObjectiveTest::getMockObjective ( bool  $does_op_already_exist,
int  $context_id,
string  $operation_name 
)
protected

Definition at line 62 of file ilOrgUnitOperationRegisteredObjectiveTest.php.

Referenced by testAchieve(), testGetHash(), testGetPreconditions(), testIsApplicable(), and testIsApplicableInvalidContextException().

67  $obj = $this
68  ->getMockBuilder(
69  ilOrgUnitOperationRegisteredObjective::class
70  )
71  ->setConstructorArgs([$operation_name, $this->description, 'context'])
72  ->onlyMethods(['getContextId', 'doesOperationExistInContext'])
73  ->getMock();
74 
75  $obj
76  ->method('getContextId')
77  ->with($this->isInstanceOf(ilDBInterface::class), 'context')
78  ->willReturn($context_id);
79  $obj
80  ->method('doesOperationExistInContext')
81  ->with($this->isInstanceOf(ilDBInterface::class), $context_id, $operation_name)
82  ->willReturn($does_op_already_exist);
83 
84  return $obj;
85  }
+ Here is the caller graph for this function:

◆ testAchieve()

ilOrgUnitOperationRegisteredObjectiveTest::testAchieve ( )

Definition at line 127 of file ilOrgUnitOperationRegisteredObjectiveTest.php.

References getMockEnviroment(), and getMockObjective().

127  : void
128  {
129  $env = $this->getMockEnviroment(true, 13);
130  $obj = $this->getMockObjective(false, 13, $this->operation);
131  $obj->achieve($env);
132  }
getMockObjective(bool $does_op_already_exist, int $context_id, string $operation_name)
getMockEnviroment(bool $expect_insert, int $expected_context_id=0)
+ Here is the call graph for this function:

◆ testGetHash()

ilOrgUnitOperationRegisteredObjectiveTest::testGetHash ( )
protected

Definition at line 87 of file ilOrgUnitOperationRegisteredObjectiveTest.php.

References getMockObjective().

87  : void
88  {
89  $obj1 = $this->getMockObjective(true, 0, $this->operation);
90  $obj2 = $this->getMockObjective(true, 0, 'other op');
91  $this->assertNotEquals(
92  $obj1->getHash(),
93  $obj2->getHash()
94  );
95  }
getMockObjective(bool $does_op_already_exist, int $context_id, string $operation_name)
+ Here is the call graph for this function:

◆ testGetPreconditions()

ilOrgUnitOperationRegisteredObjectiveTest::testGetPreconditions ( )
protected

Definition at line 97 of file ilOrgUnitOperationRegisteredObjectiveTest.php.

References getMockObjective().

97  : void
98  {
99  $env = $this->createMock(Environment::class);
100  $obj = $this->getMockObjective(true, 0, $this->operation, '');
101  $this->assertContainsOnlyInstancesOf(
102  ilDatabaseInitializedObjective::class,
103  $obj->getPreconditions($env)
104  );
105  }
getMockObjective(bool $does_op_already_exist, int $context_id, string $operation_name)
+ Here is the call graph for this function:

◆ testIsApplicable()

ilOrgUnitOperationRegisteredObjectiveTest::testIsApplicable ( )

Definition at line 107 of file ilOrgUnitOperationRegisteredObjectiveTest.php.

References getMockEnviroment(), and getMockObjective().

107  : void
108  {
109  $env = $this->getMockEnviroment(false);
110 
111  $obj = $this->getMockObjective(false, 9, $this->operation);
112  $this->assertTrue($obj->isApplicable($env));
113 
114  $obj = $this->getMockObjective(true, 9, $this->operation);
115  $this->assertNotTrue($obj->isApplicable($env));
116  }
getMockObjective(bool $does_op_already_exist, int $context_id, string $operation_name)
getMockEnviroment(bool $expect_insert, int $expected_context_id=0)
+ Here is the call graph for this function:

◆ testIsApplicableInvalidContextException()

ilOrgUnitOperationRegisteredObjectiveTest::testIsApplicableInvalidContextException ( )

Definition at line 118 of file ilOrgUnitOperationRegisteredObjectiveTest.php.

References getMockEnviroment(), and getMockObjective().

118  : void
119  {
120  $env = $this->getMockEnviroment(false);
121 
122  $obj = $this->getMockObjective(false, 0, $this->operation);
123  $this->expectException(Exception::class);
124  $obj->isApplicable($env);
125  }
getMockObjective(bool $does_op_already_exist, int $context_id, string $operation_name)
getMockEnviroment(bool $expect_insert, int $expected_context_id=0)
+ Here is the call graph for this function:

Field Documentation

◆ $description

string ilOrgUnitOperationRegisteredObjectiveTest::$description = 'description'
protected

◆ $next_id

int ilOrgUnitOperationRegisteredObjectiveTest::$next_id = 3
protected

◆ $operation

string ilOrgUnitOperationRegisteredObjectiveTest::$operation = 'first operation'
protected

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