19declare(strict_types=1);
21use PHPUnit\Framework\MockObject\MockObject;
23use PHPUnit\Framework\Attributes\PreserveGlobalState;
24use PHPUnit\Framework\Attributes\RunInSeparateProcess;
25use PHPUnit\Framework\TestCase;
49 protected function setUp(): void
52 $this->dic_backup = is_object(
$DIC) ? clone
$DIC :
null;
55 $DIC[
'resource_storage'] = $this->storage_mock = $this->createMock(Services::class);
56 $this->manager_mock = $this->createMock(Manager::class);
57 $DIC[
'ilUser'] = $this->createMock(ilObjUser::class);
58 $DIC[
'ilUser']->method(
'getPref')->willReturn(
'en');
59 $DIC[
'ilDB'] = $this->db_mock = $this->createMock(ilDBInterface::class);
60 $DIC[
'upload'] = $this->createMock(FileUpload::class);
61 $DIC[
'ilias'] = $this->createMock(ILIAS::class);
62 $DIC[
'objDefinition'] = $this->createMock(ilObjectDefinition::class);
63 $DIC[
'ilLog'] = $this->createMock(ilLogger::class);
64 $DIC[
'ilErr'] = $this->createMock(ilErrorHandling::class);
65 $DIC[
'tree'] = $this->createMock(ilTree::class);
66 $DIC[
'tpl'] = $this->createMock(ilGlobalTemplateInterface::class);
67 $DIC[
'ilClientIniFile'] = $this->createMock(ilIniFile::class);
68 $DIC[
'ilAccess'] = $this->createMock(ilAccess::class);
69 $DIC[
'ilObjDataCache'] = $this->createMock(ilObjectDataCache::class);
70 $DIC[
'ilAppEventHandler'] = $this->createMock(ilAppEventHandler::class);
71 $DIC[
'lng'] = $this->createMock(ilLanguage::class);
72 $DIC[
'ilCtrl'] = $this->createMock(ilCtrlInterface::class);
73 $DIC[
'refinery'] = $this->createMock(Factory::class);
74 $DIC[
'http'] = $this->createMock(\
ILIAS\HTTP\Services::class);
75 $DIC[
'object.customicons.factory'] = $this->createMock(IconFactory::class);
81 if (!defined(
'ILIAS_LOG_ENABLED')) {
82 define(
'ILIAS_LOG_ENABLED',
false);
92 #[PreserveGlobalState(false)]
93 #[RunInSeparateProcess]
96 $this->markTestSkipped(
'Failed for some unknown reason.');
99 $title =
'Revision One';
100 $file_stream = Streams::ofString(
'Test Content');
104 ->willReturn($this->manager_mock);
108 ->willReturnCallback(
function ($query): MockObject {
109 $mock_object = $this->createMock(ilDBStatement::class);
110 $mock_object->method(
'fetchAssoc')->willReturn([$query]);
116 ->method(
'fetchAssoc')
117 ->willReturnCallback(
function (
ilDBStatement $statement): ?array {
123 if (str_contains($query,
'last_update')) {
134 $file = $this->getMockBuilder(ilObjFile::class)
135 ->onlyMethods([
'update'])
137 $file->method(
'update');
139 $r =
new ReflectionClass(ilObjFile::class);
140 $property = $r->getProperty(
'just_notified');
141 $property->setAccessible(
true);
142 $property->setValue($file,
true);
145 ->method(
'fetchAssoc')
159 [
'the_identification', $rid],
160 [
'the_identification', $rid],
164 ->willReturnCallback(
166 $expected = array_shift($consecutive);
167 [$eid, $ret] = $consecutive;
168 $this->assertEquals($eid,
$id);
173 $this->manager_mock->expects($this->once())
179 $revision->setVersionNumber(1);
180 $revision->setTitle($title);
182 $resource->addRevision($revision);
184 $this->manager_mock->expects($this->once())
185 ->method(
'getCurrentRevision')
187 ->willReturn($revision);
190 ->method(
'getResource')
192 ->willReturn($resource);
194 $revision_number = $file->appendStream($file_stream, $title);
195 $this->assertEquals(1, $revision_number);
196 $this->assertEquals(1, $file->getVersion());
197 $this->assertEquals($title, $file->getTitle());
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Customizing of pimple-DIC for ILIAS.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Class ResourceIdentification.
Class ilObjFileStakeholder.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.