2 use\PHPUnit\Framework\TestCase;
5 require_once(
'./libs/composer/vendor/autoload.php');
50 require_once(
'./Services/WebDAV/classes/dav/class.ilObjectDAV.php');
51 require_once(
'./Services/WebDAV/classes/class.ilWebDAVRepositoryHelper.php');
52 require_once(
'./Services/WebDAV/classes/class.ilWebDAVObjDAVHelper.php');
55 $this->mocked_obj = \Mockery::mock(
'ilObject');
56 $this->mocked_obj->shouldReceive([
'getRefId' => $this->ref_id]);
58 $this->mocked_dav_obj_helper = \Mockery::mock(
'ilWebDAVObjDAVHelper');
60 $this->mocked_dav_repo_helper = \Mockery::mock(
'ilWebDAVRepositoryHelper');
62 $this->dav_obj = $this->
setUpObjectDAV($this->mocked_obj, $this->mocked_dav_repo_helper, $this->mocked_dav_obj_helper);
83 $exception_thrown =
false;
86 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withArgs([
'write', $this->ref_id])->andReturn(
false);
88 $this->mocked_obj->shouldNotReceive(
'setTitle');
93 $this->dav_obj->setName(
$title);
95 $exception_thrown = $e->getMessage() ==
'Permission denied';
99 $this->assertTrue($exception_thrown);
109 $exception_thrown =
false;
112 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withAnyArgs()->andReturn(
true);
113 $this->mocked_dav_obj_helper->shouldReceive(
'isDAVableObjTitle')->with(
$title)->andReturn(
false);
115 $this->mocked_obj = \Mockery::mock(
'ilObject');
116 $this->mocked_obj->shouldNotReceive(
'setTitle');
120 $this->dav_obj->setName(
$title);
122 $exception_thrown = $e->getMessage() ==
'Forbidden characters in title';
126 $this->assertTrue($exception_thrown);
142 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withAnyArgs()->andReturn(
true);
143 $this->mocked_dav_obj_helper->shouldReceive(
'isDAVableObjTitle')->with(
$title)->andReturn(
true);
145 $this->mocked_obj->shouldReceive(
'setTitle')->withArgs([
$title]);
146 $this->mocked_obj->shouldReceive(
'update');
149 $this->dav_obj->setName(
$title);
152 $this->assertTrue($this->mocked_obj->shouldHaveReceived(
'setTitle')->withArgs([
$title])
153 && $this->mocked_obj->shouldHaveReceived(
'update'));
163 $exception_thrown =
false;
165 $this->mocked_dav_repo_helper->shouldReceive(
'checkAccess')->withAnyArgs()->andReturn(
false);
169 $this->dav_obj->delete();
171 $exception_thrown = $e->getMessage() ==
"Permission denied";
175 $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()