2 use \PHPUnit\Framework\TestCase;
3 use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
47 protected function setUp() : void
50 $this->mocked_obj = \Mockery::mock(
'ilObject');
51 $this->mocked_obj->shouldReceive([
'getRefId' => $this->ref_id]);
53 $this->mocked_dav_obj_helper = \Mockery::mock(
'ilWebDAVObjDAVHelper');
55 $this->mocked_dav_repo_helper = \Mockery::mock(
'ilWebDAVRepositoryHelper');
57 $this->dav_obj = $this->
setUpObjectDAV($this->mocked_obj, $this->mocked_dav_repo_helper, $this->mocked_dav_obj_helper);
78 $exception_thrown =
false;
81 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withArgs([
'write', $this->ref_id])->andReturn(
false);
83 $this->mocked_obj->shouldNotReceive(
'setTitle');
88 $this->dav_obj->setName($title);
89 }
catch (Forbidden
$e) {
90 $exception_thrown = $e->getMessage() ==
'Permission denied';
94 $this->assertTrue($exception_thrown);
104 $exception_thrown =
false;
107 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withAnyArgs()->andReturn(
true);
108 $this->mocked_dav_obj_helper->shouldReceive(
'isDAVableObjTitle')->with($title)->andReturn(
false);
110 $this->mocked_obj = \Mockery::mock(
'ilObject');
111 $this->mocked_obj->shouldNotReceive(
'setTitle');
115 $this->dav_obj->setName($title);
116 }
catch (Forbidden
$e) {
117 $exception_thrown = $e->getMessage() ==
'Forbidden characters in title';
121 $this->assertTrue($exception_thrown);
137 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withAnyArgs()->andReturn(
true);
138 $this->mocked_dav_obj_helper->shouldReceive(
'isDAVableObjTitle')->with($title)->andReturn(
true);
140 $this->mocked_obj->shouldReceive(
'setTitle')->withArgs([$title]);
141 $this->mocked_obj->shouldReceive(
'update');
144 $this->dav_obj->setName($title);
147 $this->assertTrue($this->mocked_obj->shouldHaveReceived(
'setTitle')->withArgs([$title])
148 && $this->mocked_obj->shouldHaveReceived(
'update'));
158 $exception_thrown =
false;
160 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withAnyArgs()->andReturn(
false);
164 $this->dav_obj->delete();
165 }
catch (Forbidden
$e) {
166 $exception_thrown = $e->getMessage() ==
"Permission denied";
170 $this->assertTrue($exception_thrown);
TestCase for the ilObjectDAVTest.
setName_ForbiddenCharacters_ThrowForbidden()
setUpObjectDAV($mocked_obj, $mocked_repo_helper, $mockes_dav_helper)
Setup instance for ilObjectDAV.
setName_NoWriteAccess_ThrowForbidden()
setName_EverythingFine_SetTitleForObject()
Requirements:
delete_WithoutPermission_ThrowForbidden()