ILIAS  release_7 Revision v7.30-3-g800a261c036
AbstractBaseResourceBuilderTest.php
Go to the documentation of this file.
1<?php
2
4
5require_once('AbstractBaseTest.php');
6
12use Psr\Http\Message\UploadedFileInterface;
21
22require_once('DummyIDGenerator.php');
23
29{
33 protected $revision;
37 protected $information;
41 protected $upload_result;
69 protected $locking;
74
75 protected function setUp() : void
76 {
77 parent::setUp();
78 $this->storage_handler = $this->createMock(StorageHandler::class);
79 $this->storage_handler_factory = $this->createMock(StorageHandlerFactory::class);
80 $this->revision_repository = $this->createMock(RevisionRepository::class);
81 $this->resource_repository = $this->createMock(ResourceRepository::class);
82 $this->information_repository = $this->createMock(InformationRepository::class);
83 $this->stakeholder_repository = $this->createMock(StakeholderRepository::class);
84 $this->locking = $this->createMock(LockHandler::class);
85 $this->information = $this->createMock(Information::class);
86 $this->revision = $this->createMock(Revision::class);
87 }
88
98 protected function mockResourceAndRevision(
99 string $expected_file_name,
100 string $expected_mime_type,
101 int $expected_size,
102 int $expected_version_number,
103 int $expected_owner_id
104 ) : array {
105 $identification = $this->id_generator->getUniqueResourceIdentification();
106
108 $expected_file_name,
109 $expected_mime_type,
110 $expected_size
111 );
112
113 $info_resolver = new UploadInfoResolver(
115 $expected_version_number,
116 $expected_owner_id,
117 $upload_result->getName()
118 );
119
120 // MOCKS
121 $blank_resource = new StorableFileResource($identification);
122 $this->resource_repository->expects($this->once())
123 ->method('blank')
124 ->willReturn($blank_resource);
125
126 $blank_revision = new UploadedFileRevision($blank_resource->getIdentification(), $upload_result);
127 $blank_revision->setVersionNumber($info_resolver->getNextVersionNumber());
128 $this->revision_repository->expects($this->once())
129 ->method('blankFromUpload')
130 ->with(
131 $info_resolver,
132 $blank_resource,
134 )
135 ->willReturn($blank_revision);
136 return array($upload_result, $info_resolver, $identification);
137 }
138}
139
An exception for terminatinating execution or to throw for unit testing.
mockResourceAndRevision(string $expected_file_name, string $expected_mime_type, int $expected_size, int $expected_version_number, int $expected_owner_id)
getDummyUploadResult(string $file_name, string $mime_type, int $size)