ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
HandlerTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestCase;
24
25class HandlerTest extends TestCase
26{
27 protected function getHandler(): Handler
28 {
29 return new class () extends Handler {
30 protected function getInstID(): string
31 {
32 return '1234';
33 }
34 };
35 }
36
37 public function testbuildIdentifierFromEntryID(): void
38 {
39 $handler = $this->getHandler();
40
41 $identifier = $handler->buildIdentifierFromEntryID(32);
42
43 $this->assertSame(
44 'il_copyright_entry__1234__32',
45 $identifier
46 );
47 }
48
49 public function testIsIdentifierValidTrue(): void
50 {
51 $handler = $this->getHandler();
52
53 $this->assertTrue(
54 $handler->isIdentifierValid('il_copyright_entry__1234__32')
55 );
56 }
57
59 {
60 $handler = $this->getHandler();
61
62 $this->assertFalse(
63 $handler->isIdentifierValid('invalid string')
64 );
65 }
66
68 {
69 $handler = $this->getHandler();
70
71 $this->assertFalse(
72 $handler->isIdentifierValid('il_copyright_entry__999__32')
73 );
74 }
75
76 public function testParseEntryIDFromIdentifier(): void
77 {
78 $handler = $this->getHandler();
79
80 $entry_id = $handler->parseEntryIDFromIdentifier('il_copyright_entry__1234__32');
81
82 $this->assertSame(32, $entry_id);
83 }
84
86 {
87 $handler = $this->getHandler();
88
89 $entry_id = $handler->parseEntryIDFromIdentifier('invalid string');
90
91 $this->assertSame(0, $entry_id);
92 }
93
95 {
96 $handler = $this->getHandler();
97
98 $entry_id = $handler->parseEntryIDFromIdentifier('il_copyright_entry__999__32');
99
100 $this->assertSame(0, $entry_id);
101 }
102}
$handler
Definition: oai.php:29