28 use Slim\Psr7\Request;
30 use Slim\Psr7\Factory\StreamFactory;
31 use Slim\Psr7\Headers;
88 $container = M::mock(
'ContainerBuilder');
89 $this->dbHelper = M::mock(DbHelper::class);
90 $this->restHelper = M::mock(RestHelper::class);
91 $this->userDao = M::mock(UserDao::class);
92 $this->uploadDao = M::mock(UploadDao::class);
93 $this->auth = M::mock(Auth::class);
94 $this->copyrightDao = M::mock(CopyrightDao::class);
95 $this->copyrightHist = M::mock(
'ajax_copyright_hist');
97 $this->restHelper->shouldReceive(
'getDbHelper')->andReturn($this->dbHelper);
98 $this->restHelper->shouldReceive(
'getPlugin')
99 ->withArgs([
'ajax_copyright_hist'])->andReturn($this->copyrightHist);
100 $this->restHelper->shouldReceive(
'getUploadDao')
101 ->andReturn($this->uploadDao);
102 $container->shouldReceive(
'get')->withArgs(array(
103 'helper.restHelper'))->andReturn($this->restHelper);
104 $container->shouldReceive(
'get')->withArgs(array(
106 ))->andReturn($this->copyrightDao);
107 $this->streamFactory =
new StreamFactory();
119 $response->getBody()->seek(0);
120 return json_decode($response->getBody()->getContents(),
true);
133 $this->dbHelper->shouldReceive(
"doesIdExist")
134 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
false);
135 $requestHeaders =
new Headers();
136 $body = $this->streamFactory->createStream();
137 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
138 $requestHeaders, [], [], $body);
139 $request = $request->withQueryParams([]);
140 $this->expectException(HttpNotFoundException::class);
141 $this->copyrightController->getTotalFileCopyrights($request,
new ResponseHelper(),$args);
155 $this->dbHelper->shouldReceive(
"doesIdExist")
156 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
157 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
158 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
159 $this->restHelper->shouldReceive(
"getGroupId")
161 $this->uploadDao->shouldReceive(
"isAccessible")
162 ->withArgs([$args[
'id'],4])->andReturn(
true);
163 $this->dbHelper->shouldReceive(
"doesIdExist")
164 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
false);
166 $requestHeaders =
new Headers();
167 $body = $this->streamFactory->createStream();
168 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
169 $requestHeaders, [], [], $body);
170 $request = $request->withQueryParams([]);
171 $this->expectException(HttpNotFoundException::class);
172 $this->copyrightController->getTotalFileCopyrights($request,
new ResponseHelper(),$args);
187 $this->dbHelper->shouldReceive(
"doesIdExist")
188 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
189 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
190 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
191 $this->restHelper->shouldReceive(
"getGroupId")
193 $this->uploadDao->shouldReceive(
"isAccessible")
194 ->withArgs([$args[
'id'],4])->andReturn(
true);
195 $this->dbHelper->shouldReceive(
"doesIdExist")
196 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
198 $requestHeaders =
new Headers();
199 $body = $this->streamFactory->createStream();
200 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
201 $requestHeaders, [], [], $body);
202 $request = $request->withQueryParams([]);
203 $this->expectException(HttpBadRequestException::class);
204 $this->copyrightController->getTotalFileCopyrights($request,
new ResponseHelper(),$args);
220 $this->dbHelper->shouldReceive(
"doesIdExist")
221 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
222 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
223 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
224 $this->restHelper->shouldReceive(
"getGroupId")
226 $this->uploadDao->shouldReceive(
"isAccessible")
227 ->withArgs([$args[
'id'],4])->andReturn(
true);
228 $this->dbHelper->shouldReceive(
"doesIdExist")
229 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
230 $this->copyrightHist->shouldReceive(
'getAgentId')
231 ->withArgs([$args[
'id'],
'copyright_ars'])->andReturn(1);
232 $this->copyrightDao->shouldReceive(
'getTotalCopyrights')
233 ->withArgs([$args[
'id'],4,
'uploadtree',3])->andReturn(10);
235 $requestHeaders =
new Headers();
236 $body = $this->streamFactory->createStream();
237 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
238 $requestHeaders, [], [], $body);
239 $request = $request->withQueryParams([
"status" =>
"invalid"]);
240 $this->expectException(HttpBadRequestException::class);
242 $expectedResponse = (
new ResponseHelper())->withJson(array(
'total_copyrights' => 10));
243 $actualResponse = $this->copyrightController->getTotalFileCopyrights($request,
new ResponseHelper(),$args);
244 $this->assertEquals($expectedResponse, $actualResponse);
246 $this->assertEquals(200,$actualResponse->getStatusCode());
260 $requestHeaders =
new Headers();
261 $requestHeaders->setHeader(
'limit', 0);
262 $body = $this->streamFactory->createStream();
263 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
264 $requestHeaders, [], [], $body);
265 $request = $request->withQueryParams([
"status" =>
"invalid"]);
266 $this->expectException(HttpBadRequestException::class);
267 $this->copyrightController->getFileCopyrights($request,
new ResponseHelper(),$args);
280 $dumRows = $this->getDummyData()[
'dumRows'];
281 $args = $this->getDummyData()[
'args'];
283 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
284 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
285 $this->dbHelper->shouldReceive(
"doesIdExist")
286 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
287 $this->dbHelper->shouldReceive(
"doesIdExist")
288 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
289 $this->restHelper->shouldReceive(
"getGroupId")
291 $this->uploadDao->shouldReceive(
"isAccessible")
292 ->withArgs([$args[
'id'],4])->andReturn(
true);
293 $this->copyrightHist->shouldReceive(
'getAgentId')
294 ->withArgs([$args[
'id'],
'copyright_ars'])->andReturn(1);
296 $this->copyrightHist->shouldReceive(
'getCopyrights')
297 ->withArgs([$args[
'id'],2,
'uploadtree',1,
'statement',
'active',
true,0,100])->andReturn([$dumRows,10,10]);
298 $requestHeaders =
new Headers();
299 $requestHeaders->setHeader(
'limit', 100);
300 $body = $this->streamFactory->createStream();
301 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
302 $requestHeaders, [], [], $body);
303 $request = $request->withQueryParams([
"status" =>
"active"]);
305 foreach ($dumRows as $row) {
306 $row[
'count'] = intval($row[
'copyright_count']);
307 unset($row[
'copyright_count']);
310 $totalPages = intval(ceil(10/100));
311 $expectedResponse = (
new ResponseHelper())->withHeader(
'X-Total-Pages',$totalPages)->withJson($finalVal,200);
312 $actualResponse = $this->copyrightController->getFileCopyrights($request,
new ResponseHelper(),$args);
314 $this->assertEquals(200,$actualResponse->getStatusCode());
329 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
330 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
331 $this->dbHelper->shouldReceive(
"doesIdExist")
332 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
333 $this->dbHelper->shouldReceive(
"doesIdExist")
334 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
335 $this->restHelper->shouldReceive(
"getGroupId")
337 $this->uploadDao->shouldReceive(
"isAccessible")
338 ->withArgs([$args[
'id'],4])->andReturn(
true);
339 $this->copyrightHist->shouldReceive(
'getAgentId')
340 ->withArgs([$args[
'id'],
'copyright_ars'])->andReturn(1);
342 $requestHeaders =
new Headers();
343 $requestHeaders->setHeader(
'limit', 100);
344 $requestHeaders->setHeader(
"page",-1);
345 $body = $this->streamFactory->createStream();
346 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
347 $requestHeaders, [], [], $body);
348 $request = $request->withQueryParams([
"status" =>
"active"]);
350 $this->expectException(HttpBadRequestException::class);
351 $this->copyrightController->getFileCopyrights($request,
new ResponseHelper(),$args);
355 public function getDummyData()
360 "copyright_count" => 10,
364 "copyright_count" => 12,
372 'dumRows' => $dumRows,
384 $dumRows = $this->getDummyData()[
'dumRows'];
385 $args = $this->getDummyData()[
'args'];
386 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
387 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
388 $this->dbHelper->shouldReceive(
"doesIdExist")
389 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
390 $this->dbHelper->shouldReceive(
"doesIdExist")
391 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
392 $this->restHelper->shouldReceive(
"getGroupId")
394 $this->uploadDao->shouldReceive(
"isAccessible")
395 ->withArgs([$args[
'id'],4])->andReturn(
true);
396 $this->copyrightHist->shouldReceive(
'getAgentId')
397 ->withArgs([$args[
'id'],
'copyright_ars'])->andReturn(1);
399 $this->copyrightHist->shouldReceive(
'getCopyrights')
400 ->withArgs([$args[
'id'],2,
'uploadtree',1,
'email',
'active',
true,0,100])->andReturn([$dumRows,10,10]);
401 $requestHeaders =
new Headers();
402 $requestHeaders->setHeader(
'limit', 100);
403 $body = $this->streamFactory->createStream();
404 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
405 $requestHeaders, [], [], $body);
406 $request = $request->withQueryParams([
"status" =>
"active"]);
408 foreach ($dumRows as $row) {
409 $row[
'count'] = intval($row[
'copyright_count']);
410 unset($row[
'copyright_count']);
413 $totalPages = intval(ceil(10/100));
414 $expectedResponse = (
new ResponseHelper())->withHeader(
'X-Total-Pages',$totalPages)->withJson($finalVal,200);
415 $actualResponse = $this->copyrightController->getFileEmail($request,
new ResponseHelper(),$args);
417 $this->assertEquals(200,$actualResponse->getStatusCode());
430 $dumRows = $this->getDummyData()[
'dumRows'];
431 $args = $this->getDummyData()[
'args'];
432 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
433 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
434 $this->dbHelper->shouldReceive(
"doesIdExist")
435 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
436 $this->dbHelper->shouldReceive(
"doesIdExist")
437 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
438 $this->restHelper->shouldReceive(
"getGroupId")
440 $this->uploadDao->shouldReceive(
"isAccessible")
441 ->withArgs([$args[
'id'],4])->andReturn(
true);
442 $this->copyrightHist->shouldReceive(
'getAgentId')
443 ->withArgs([$args[
'id'],
'copyright_ars'])->andReturn(1);
445 $this->copyrightHist->shouldReceive(
'getCopyrights')
446 ->withArgs([$args[
'id'],2,
'uploadtree',1,
'url',
'active',
true,0,100])->andReturn([$dumRows,10,10]);
447 $requestHeaders =
new Headers();
448 $requestHeaders->setHeader(
'limit', 100);
449 $body = $this->streamFactory->createStream();
450 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
451 $requestHeaders, [], [], $body);
452 $request = $request->withQueryParams([
"status" =>
"active"]);
454 foreach ($dumRows as $row) {
455 $row[
'count'] = intval($row[
'copyright_count']);
456 unset($row[
'copyright_count']);
459 $totalPages = intval(ceil(10/100));
460 $expectedResponse = (
new ResponseHelper())->withHeader(
'X-Total-Pages',$totalPages)->withJson($finalVal,200);
461 $actualResponse = $this->copyrightController->getFileUrl($request,
new ResponseHelper(),$args);
463 $this->assertEquals(200,$actualResponse->getStatusCode());
477 $dumRows = $this->getDummyData()[
'dumRows'];
478 $args = $this->getDummyData()[
'args'];
479 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
480 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
481 $this->dbHelper->shouldReceive(
"doesIdExist")
482 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
483 $this->dbHelper->shouldReceive(
"doesIdExist")
484 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
485 $this->restHelper->shouldReceive(
"getGroupId")
487 $this->uploadDao->shouldReceive(
"isAccessible")
488 ->withArgs([$args[
'id'],4])->andReturn(
true);
489 $this->copyrightHist->shouldReceive(
'getAgentId')
490 ->withArgs([$args[
'id'],
'copyright_ars'])->andReturn(1);
492 $this->copyrightHist->shouldReceive(
'getCopyrights')
493 ->withArgs([$args[
'id'],2,
'uploadtree',1,
'author',
'active',
true,0,100])->andReturn([$dumRows,10,10]);
494 $requestHeaders =
new Headers();
495 $requestHeaders->setHeader(
'limit', 100);
496 $body = $this->streamFactory->createStream();
497 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
498 $requestHeaders, [], [], $body);
499 $request = $request->withQueryParams([
"status" =>
"active"]);
501 foreach ($dumRows as $row) {
502 $row[
'count'] = intval($row[
'copyright_count']);
503 unset($row[
'copyright_count']);
506 $totalPages = intval(ceil(10/100));
507 $expectedResponse = (
new ResponseHelper())->withHeader(
'X-Total-Pages',$totalPages)->withJson($finalVal,200);
508 $actualResponse = $this->copyrightController->getFileAuthor($request,
new ResponseHelper(),$args);
510 $this->assertEquals(200,$actualResponse->getStatusCode());
522 $dumRows = $this->getDummyData()[
'dumRows'];
523 $args = $this->getDummyData()[
'args'];
524 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
525 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
526 $this->dbHelper->shouldReceive(
"doesIdExist")
527 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
528 $this->dbHelper->shouldReceive(
"doesIdExist")
529 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
530 $this->restHelper->shouldReceive(
"getGroupId")
532 $this->uploadDao->shouldReceive(
"isAccessible")
533 ->withArgs([$args[
'id'],4])->andReturn(
true);
534 $this->copyrightHist->shouldReceive(
'getAgentId')
535 ->withArgs([$args[
'id'],
'ecc_ars'])->andReturn(1);
537 $this->copyrightHist->shouldReceive(
'getCopyrights')
538 ->withArgs([$args[
'id'],2,
'uploadtree',1,
'ecc',
'active',
true,0,100])->andReturn([$dumRows,10,10]);
539 $requestHeaders =
new Headers();
540 $requestHeaders->setHeader(
'limit', 100);
541 $body = $this->streamFactory->createStream();
542 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
543 $requestHeaders, [], [], $body);
544 $request = $request->withQueryParams([
"status" =>
"active"]);
546 foreach ($dumRows as $row) {
547 $row[
'count'] = intval($row[
'copyright_count']);
548 unset($row[
'copyright_count']);
551 $totalPages = intval(ceil(10/100));
552 $expectedResponse = (
new ResponseHelper())->withHeader(
'X-Total-Pages',$totalPages)->withJson($finalVal,200);
553 $actualResponse = $this->copyrightController->getFileEcc($request,
new ResponseHelper(),$args);
555 $this->assertEquals(200,$actualResponse->getStatusCode());
568 $dumRows = $this->getDummyData()[
'dumRows'];
569 $args = $this->getDummyData()[
'args'];
570 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
571 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
572 $this->dbHelper->shouldReceive(
"doesIdExist")
573 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
574 $this->dbHelper->shouldReceive(
"doesIdExist")
575 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
576 $this->restHelper->shouldReceive(
"getGroupId")
578 $this->uploadDao->shouldReceive(
"isAccessible")
579 ->withArgs([$args[
'id'],4])->andReturn(
true);
580 $this->copyrightHist->shouldReceive(
'getAgentId')
581 ->withArgs([$args[
'id'],
'keyword_ars'])->andReturn(1);
583 $this->copyrightHist->shouldReceive(
'getCopyrights')
584 ->withArgs([$args[
'id'],2,
'uploadtree',1,
'keyword',
'active',
true,0,100])->andReturn([$dumRows,10,10]);
585 $requestHeaders =
new Headers();
586 $requestHeaders->setHeader(
'limit', 100);
587 $body = $this->streamFactory->createStream();
588 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
589 $requestHeaders, [], [], $body);
590 $request = $request->withQueryParams([
"status" =>
"active"]);
592 foreach ($dumRows as $row) {
593 $row[
'count'] = intval($row[
'copyright_count']);
594 unset($row[
'copyright_count']);
597 $totalPages = intval(ceil(10/100));
598 $expectedResponse = (
new ResponseHelper())->withHeader(
'X-Total-Pages',$totalPages)->withJson($finalVal,200);
599 $actualResponse = $this->copyrightController->getFileKeyword($request,
new ResponseHelper(),$args);
601 $this->assertEquals(200,$actualResponse->getStatusCode());
613 $dumRows = $this->getDummyData()[
'dumRows'];
614 $args = $this->getDummyData()[
'args'];
615 $this->uploadDao->shouldReceive(
"getUploadtreeTableName")
616 ->withArgs([$args[
'id']])->andReturn(
"uploadtree");
617 $this->dbHelper->shouldReceive(
"doesIdExist")
618 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
619 $this->dbHelper->shouldReceive(
"doesIdExist")
620 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
621 $this->restHelper->shouldReceive(
"getGroupId")
623 $this->uploadDao->shouldReceive(
"isAccessible")
624 ->withArgs([$args[
'id'],4])->andReturn(
true);
625 $this->copyrightHist->shouldReceive(
'getAgentId')
626 ->withArgs([$args[
'id'],
'ipra_ars'])->andReturn(1);
628 $this->copyrightHist->shouldReceive(
'getCopyrights')
629 ->withArgs([$args[
'id'],2,
'uploadtree',1,
'ipra',
'active',
true,0,100])->andReturn([$dumRows,10,10]);
630 $requestHeaders =
new Headers();
631 $requestHeaders->setHeader(
'limit', 100);
632 $body = $this->streamFactory->createStream();
633 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
634 $requestHeaders, [], [], $body);
635 $request = $request->withQueryParams([
"status" =>
"active"]);
637 foreach ($dumRows as $row) {
638 $row[
'count'] = intval($row[
'copyright_count']);
639 unset($row[
'copyright_count']);
642 $totalPages = intval(ceil(10/100));
643 $expectedResponse = (
new ResponseHelper())->withHeader(
'X-Total-Pages',$totalPages)->withJson($finalVal,200);
644 $actualResponse = $this->copyrightController->getFileIpra($request,
new ResponseHelper(),$args);
646 $this->assertEquals(200,$actualResponse->getStatusCode());
657 $args = $this->getDummyData()[
'args'];
658 $args[
'hash'] =
"hash";
664 'uploadTreeTableName' =>
"uploadtree",
668 $this->dbHelper->shouldReceive(
"doesIdExist")
669 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
670 $this->dbHelper->shouldReceive(
"doesIdExist")
671 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
672 $this->restHelper->shouldReceive(
"getGroupId")
674 $this->uploadDao->shouldReceive(
"isAccessible")
675 ->withArgs([$args[
'id'],4])->andReturn(
true);
677 $this->uploadDao->shouldReceive(
"getUploadTreeTableName")
678 ->withAnyArgs()->andReturn(
"uploadtree");
680 $this->restHelper->shouldReceive(
"getUserId")
681 ->andReturn($userId);
682 $this->copyrightHist->shouldReceive(
'getTableName')
683 ->withArgs([
'statement'])->andReturn(
"statement");
684 $this->uploadDao->shouldReceive(
"getItemTreeBounds")
685 ->andReturn($itemTreeBounds);
686 $this->copyrightDao->shouldReceive(
'updateTable');
688 $requestHeaders =
new Headers();
689 $body = $this->streamFactory->createStream();
690 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
691 $requestHeaders, [], [], $body);
692 $request = $request->withQueryParams([
"status" =>
"active"]);
694 $returnVal =
new Info(200,
"Successfully removed copyright.", InfoType::INFO);
695 $expectedResponse = (
new ResponseHelper())->withJson($returnVal->getArray(),$returnVal->getCode());
696 $actualResponse = $this->copyrightController->deleteFileCopyright($request,
new ResponseHelper(),$args);
710 $args = $this->getDummyData()[
'args'];
711 $args[
'hash'] =
"hash";
717 'uploadTreeTableName' =>
"uploadtree",
721 $this->dbHelper->shouldReceive(
"doesIdExist")
722 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
723 $this->dbHelper->shouldReceive(
"doesIdExist")
724 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
725 $this->restHelper->shouldReceive(
"getGroupId")
727 $this->uploadDao->shouldReceive(
"isAccessible")
728 ->withArgs([$args[
'id'],4])->andReturn(
true);
730 $this->uploadDao->shouldReceive(
"getUploadTreeTableName")
731 ->withAnyArgs()->andReturn(
"uploadtree");
733 $this->restHelper->shouldReceive(
"getUserId")
734 ->andReturn($userId);
735 $this->copyrightHist->shouldReceive(
'getTableName')
736 ->withArgs([
'email'])->andReturn(
"copyrights");
737 $this->uploadDao->shouldReceive(
"getItemTreeBounds")
738 ->andReturn($itemTreeBounds);
739 $this->copyrightDao->shouldReceive(
'updateTable');
741 $requestHeaders =
new Headers();
742 $body = $this->streamFactory->createStream();
743 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
744 $requestHeaders, [], [], $body);
745 $request = $request->withQueryParams([
"status" =>
"active"]);
747 $returnVal =
new Info(200,
"Successfully removed email.", InfoType::INFO);
748 $expectedResponse = (
new ResponseHelper())->withJson($returnVal->getArray(),$returnVal->getCode());
749 $actualResponse = $this->copyrightController->deleteFileEmail($request,
new ResponseHelper(),$args);
762 $args = $this->getDummyData()[
'args'];
763 $args[
'hash'] =
"hash";
769 'uploadTreeTableName' =>
"uploadtree",
773 $this->dbHelper->shouldReceive(
"doesIdExist")
774 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
775 $this->dbHelper->shouldReceive(
"doesIdExist")
776 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
777 $this->restHelper->shouldReceive(
"getGroupId")
779 $this->uploadDao->shouldReceive(
"isAccessible")
780 ->withArgs([$args[
'id'],4])->andReturn(
true);
782 $this->uploadDao->shouldReceive(
"getUploadTreeTableName")
783 ->withAnyArgs()->andReturn(
"uploadtree");
785 $this->restHelper->shouldReceive(
"getUserId")
786 ->andReturn($userId);
787 $this->copyrightHist->shouldReceive(
'getTableName')
788 ->withArgs([
'url'])->andReturn(
"copyrights");
789 $this->uploadDao->shouldReceive(
"getItemTreeBounds")
790 ->andReturn($itemTreeBounds);
791 $this->copyrightDao->shouldReceive(
'updateTable');
793 $requestHeaders =
new Headers();
794 $body = $this->streamFactory->createStream();
795 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
796 $requestHeaders, [], [], $body);
797 $request = $request->withQueryParams([
"status" =>
"active"]);
799 $returnVal =
new Info(200,
"Successfully removed url.", InfoType::INFO);
800 $expectedResponse = (
new ResponseHelper())->withJson($returnVal->getArray(),$returnVal->getCode());
801 $actualResponse = $this->copyrightController->deleteFileUrl($request,
new ResponseHelper(),$args);
817 $args = $this->getDummyData()[
'args'];
818 $args[
'hash'] =
"hash";
824 'uploadTreeTableName' =>
"uploadtree",
828 $this->dbHelper->shouldReceive(
"doesIdExist")
829 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
830 $this->dbHelper->shouldReceive(
"doesIdExist")
831 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
832 $this->restHelper->shouldReceive(
"getGroupId")
834 $this->uploadDao->shouldReceive(
"isAccessible")
835 ->withArgs([$args[
'id'],4])->andReturn(
true);
837 $this->uploadDao->shouldReceive(
"getUploadTreeTableName")
838 ->withAnyArgs()->andReturn(
"uploadtree");
840 $this->restHelper->shouldReceive(
"getUserId")
841 ->andReturn($userId);
842 $this->copyrightHist->shouldReceive(
'getTableName')
843 ->withArgs([
'author'])->andReturn(
"copyrights");
844 $this->uploadDao->shouldReceive(
"getItemTreeBounds")
845 ->andReturn($itemTreeBounds);
846 $this->copyrightDao->shouldReceive(
'updateTable');
848 $requestHeaders =
new Headers();
849 $body = $this->streamFactory->createStream();
850 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
851 $requestHeaders, [], [], $body);
852 $request = $request->withQueryParams([
"status" =>
"active"]);
854 $returnVal =
new Info(200,
"Successfully removed author.", InfoType::INFO);
855 $expectedResponse = (
new ResponseHelper())->withJson($returnVal->getArray(),$returnVal->getCode());
856 $actualResponse = $this->copyrightController->deleteFileAuthor($request,
new ResponseHelper(),$args);
869 $args = $this->getDummyData()[
'args'];
870 $args[
'hash'] =
"hash";
876 'uploadTreeTableName' =>
"uploadtree",
880 $this->dbHelper->shouldReceive(
"doesIdExist")
881 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
882 $this->dbHelper->shouldReceive(
"doesIdExist")
883 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
884 $this->restHelper->shouldReceive(
"getGroupId")
886 $this->uploadDao->shouldReceive(
"isAccessible")
887 ->withArgs([$args[
'id'],4])->andReturn(
true);
889 $this->uploadDao->shouldReceive(
"getUploadTreeTableName")
890 ->withAnyArgs()->andReturn(
"uploadtree");
892 $this->restHelper->shouldReceive(
"getUserId")
893 ->andReturn($userId);
894 $this->copyrightHist->shouldReceive(
'getTableName')
895 ->withArgs([
'ecc'])->andReturn(
"copyrights");
896 $this->uploadDao->shouldReceive(
"getItemTreeBounds")
897 ->andReturn($itemTreeBounds);
898 $this->copyrightDao->shouldReceive(
'updateTable');
900 $requestHeaders =
new Headers();
901 $body = $this->streamFactory->createStream();
902 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
903 $requestHeaders, [], [], $body);
904 $request = $request->withQueryParams([
"status" =>
"active"]);
906 $returnVal =
new Info(200,
"Successfully removed ecc.", InfoType::INFO);
907 $expectedResponse = (
new ResponseHelper())->withJson($returnVal->getArray(),$returnVal->getCode());
908 $actualResponse = $this->copyrightController->deleteFileEcc($request,
new ResponseHelper(),$args);
922 $args = $this->getDummyData()[
'args'];
923 $args[
'hash'] =
"hash";
929 'uploadTreeTableName' =>
"uploadtree",
933 $this->dbHelper->shouldReceive(
"doesIdExist")
934 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
935 $this->dbHelper->shouldReceive(
"doesIdExist")
936 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
937 $this->restHelper->shouldReceive(
"getGroupId")
939 $this->uploadDao->shouldReceive(
"isAccessible")
940 ->withArgs([$args[
'id'],4])->andReturn(
true);
942 $this->uploadDao->shouldReceive(
"getUploadTreeTableName")
943 ->withAnyArgs()->andReturn(
"uploadtree");
945 $this->restHelper->shouldReceive(
"getUserId")
946 ->andReturn($userId);
947 $this->copyrightHist->shouldReceive(
'getTableName')
948 ->withArgs([
'keyword'])->andReturn(
"copyrights");
949 $this->uploadDao->shouldReceive(
"getItemTreeBounds")
950 ->andReturn($itemTreeBounds);
951 $this->copyrightDao->shouldReceive(
'updateTable');
953 $requestHeaders =
new Headers();
954 $body = $this->streamFactory->createStream();
955 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
956 $requestHeaders, [], [], $body);
957 $request = $request->withQueryParams([
"status" =>
"active"]);
959 $returnVal =
new Info(200,
"Successfully removed keyword.", InfoType::INFO);
960 $expectedResponse = (
new ResponseHelper())->withJson($returnVal->getArray(),$returnVal->getCode());
961 $actualResponse = $this->copyrightController->deleteFileKeyword($request,
new ResponseHelper(),$args);
976 $args = $this->getDummyData()[
'args'];
977 $args[
'hash'] =
"hash";
983 'uploadTreeTableName' =>
"uploadtree",
987 $this->dbHelper->shouldReceive(
"doesIdExist")
988 ->withArgs([
'uploadtree',
'uploadtree_pk', $args[
'itemId']])->andReturn(
true);
989 $this->dbHelper->shouldReceive(
"doesIdExist")
990 ->withArgs([
'upload',
'upload_pk', $args[
'id']])->andReturn(
true);
991 $this->restHelper->shouldReceive(
"getGroupId")
993 $this->uploadDao->shouldReceive(
"isAccessible")
994 ->withArgs([$args[
'id'],4])->andReturn(
true);
996 $this->uploadDao->shouldReceive(
"getUploadTreeTableName")
997 ->withAnyArgs()->andReturn(
"uploadtree");
999 $this->restHelper->shouldReceive(
"getUserId")
1000 ->andReturn($userId);
1001 $this->copyrightHist->shouldReceive(
'getTableName')
1002 ->withArgs([
'ipra'])->andReturn(
"copyrights");
1003 $this->uploadDao->shouldReceive(
"getItemTreeBounds")
1004 ->andReturn($itemTreeBounds);
1005 $this->copyrightDao->shouldReceive(
'updateTable');
1007 $requestHeaders =
new Headers();
1008 $body = $this->streamFactory->createStream();
1009 $request =
new Request(
"GET",
new Uri(
"HTTP",
"localhost"),
1010 $requestHeaders, [], [], $body);
1011 $request = $request->withQueryParams([
"status" =>
"active"]);
1013 $returnVal =
new Info(200,
"Successfully removed ipra.", InfoType::INFO);
1014 $expectedResponse = (
new ResponseHelper())->withJson($returnVal->getArray(),$returnVal->getCode());
1015 $actualResponse = $this->copyrightController->deleteFileIpra($request,
new ResponseHelper(),$args);
Contains the constants and helpers for authentication of user.
Provides helper methods to access database for REST api.
Override Slim response for withJson function.
Provides various DAO helper functions for REST api.
Different type of infos provided by REST.
Info model to contain general error and return values.
setUp()
Setup test objects.
testGetTotalFileCopyrightsUploadNotFound()
testGetFileCopyrightsWithInvalidLimit()
testGetTotalFileCopyrightsItemNotFound()
getResponseJson($response)
testDeleteFileCopyright()
testGetTotalFileCopyrightsWithBadRequest()
testGetFileCopyrightsWithInvalidPage()
testGetTotalFileCopyrightsWithInvalidQueryParams()