19 declare(strict_types=1);
    32         'title' => 
'entry default',
    33         'description' => 
'description default',
    37         'full_name' => 
'full name default',
    38         'link' => 
'link default',
    39         'image_link' => 
'image link default',
    41         'alt_text' => 
'alt text default'    47         'description' => 
'description 1',
    51         'full_name' => 
'full name 1',
    53         'image_link' => 
'image link 1',
    55         'alt_text' => 
'alt text 1'    65         'full_name' => 
'full name 2',
    68         'image_file' => 
'image file 2',
    69         'alt_text' => 
'alt text 2'    74         $db = $this->createMock(\ilDBInterface::class);
    75         $db->method(
'quote')->willReturnCallback(fn($v) => (
string) $v);
    81         return $this->createMock(URI::class);
    91                 protected URI|MockObject $uri
    96             protected function getURI(
string $uri): 
URI    98                 $clone = clone $this->uri;
    99                 $clone->method(
'__toString')->willReturn($uri);
   108         $db->expects($this->once())
   110            ->with(
'SELECT * FROM il_md_cpr_selections WHERE entry_id = 5');
   111         $db->expects($this->once())
   112            ->method(
'fetchAssoc')
   113            ->willReturn(self::ROW_1);
   117         $entry = $repo->getEntry(5);
   118         $this->assertSame(self::ROW_1[
'entry_id'], $entry->id());
   119         $this->assertSame(self::ROW_1[
'title'], $entry->title());
   120         $this->assertSame(self::ROW_1[
'description'], $entry->description());
   121         $this->assertSame((
bool) self::ROW_1[
'is_default'], $entry->isDefault());
   122         $this->assertSame((
bool) self::ROW_1[
'outdated'], $entry->isOutdated());
   123         $this->assertSame(self::ROW_1[
'position'], $entry->position());
   124         $this->assertSame(self::ROW_1[
'full_name'], $entry->copyrightData()->fullName());
   125         $this->assertSame(self::ROW_1[
'link'], (
string) $entry->copyrightData()->link());
   126         $this->assertSame(self::ROW_1[
'image_link'], (
string) $entry->copyrightData()->imageLink());
   127         $this->assertSame(self::ROW_1[
'image_file'], $entry->copyrightData()->imageFile());
   128         $this->assertSame(self::ROW_1[
'alt_text'], $entry->copyrightData()->altText());
   129         $this->assertSame((
bool) self::ROW_1[
'is_default'], $entry->copyrightData()->fallBackToDefaultImage());
   135         $db->expects($this->once())
   137            ->with(
'SELECT * FROM il_md_cpr_selections WHERE entry_id = 67');
   138         $db->expects($this->once())
   139            ->method(
'fetchAssoc')
   140            ->willReturn(self::ROW_2);
   144         $entry = $repo->getEntry(67);
   145         $this->assertNull($entry->copyrightData()->link());
   146         $this->assertNull($entry->copyrightData()->imageLink());
   152         $db->expects($this->once())
   154            ->with(
'SELECT * FROM il_md_cpr_selections WHERE entry_id = 5');
   155         $db->expects($this->once())
   156            ->method(
'fetchAssoc')
   161         $this->assertEquals(
new NullEntry(), $repo->getEntry(5));
   167         $db->expects($this->once())
   169            ->with(
'SELECT * FROM il_md_cpr_selections WHERE is_default = 1');
   170         $db->expects($this->once())
   171            ->method(
'fetchAssoc')
   172            ->willReturn(self::ROW_DEFAULT);
   175         $this->assertInstanceOf(EntryInterface::class, $repo->getDefaultEntry());
   181         $db->expects($this->once())
   184                'SELECT * FROM il_md_cpr_selections   185             ORDER BY is_default DESC, position ASC'   187         $four_times = $this->exactly(4);
   188         $db->expects($four_times)
   189            ->method(
'fetchAssoc')
   190            ->willReturnCallback(
function () use ($four_times) {
   191                return match ($four_times->getInvocationCount()) {
   192                    1 => self::ROW_DEFAULT,
   201         $res = $repo->getAllEntries();
   202         $this->assertInstanceOf(EntryInterface::class, 
$res->current());
   204         $this->assertInstanceOf(EntryInterface::class, 
$res->current());
   206         $this->assertInstanceOf(EntryInterface::class, 
$res->current());
   208         $this->assertNull(
$res->current());
   214         $db->expects($this->once())
   217                'SELECT * FROM il_md_cpr_selections   218             ORDER BY is_default DESC, position ASC'   220         $thrice = $this->exactly(3);
   221         $db->expects($thrice)
   222            ->method(
'fetchAssoc')
   223            ->willReturnCallback(
function () use ($thrice) {
   224                return match ($thrice->getInvocationCount()) {
   225                    1 => self::ROW_DEFAULT,
   233         $res = $repo->getAllEntries();
   234         $this->assertInstanceOf(EntryInterface::class, 
$res->current());
   236         $this->assertInstanceOf(EntryInterface::class, 
$res->current());
   238         $this->assertNull(
$res->current());
   244         $db->expects($this->once())
   245            ->method(
'manipulate')
   246            ->with(
'DELETE FROM il_md_cpr_selections WHERE entry_id = 5');
   250         $repo->deleteEntry(5);
   256         $db->expects($this->once())
   259                'SELECT MAX(position) AS max FROM il_md_cpr_selections WHERE is_default = 0'   261         $db->expects($this->once())
   262            ->method(
'fetchAssoc')
   263            ->willReturn([
'max' => 5]);
   264         $db->expects($this->once())
   266            ->with(
'il_md_cpr_selections')
   268         $db->expects($this->once())
   271                'il_md_cpr_selections',
   288         $uri->method(
'__toString')->willReturn(
'new link');
   290         $img_uri->method(
'__toString')->willReturn(
'new image link');
   307         $db->expects($this->once())
   310                'SELECT MAX(position) AS max FROM il_md_cpr_selections WHERE is_default = 0'   312         $db->expects($this->once())
   313            ->method(
'fetchAssoc')
   314            ->willReturn([
'max' => 5]);
   315         $db->expects($this->once())
   317            ->with(
'il_md_cpr_selections')
   319         $db->expects($this->once())
   322                'il_md_cpr_selections',
   339         $uri->method(
'__toString')->willReturn(
'new link');
   355         $db = $this->createMock(\ilDBInterface::class);
   358         $this->expectException(\ilMDCopyrightException::class);
   359         $repo->createEntry(
'');
   365         $db->expects($this->once())
   368                'il_md_cpr_selections',
   384         $uri->method(
'__toString')->willReturn(
'new link');
   386         $img_uri->method(
'__toString')->willReturn(
'new image link');
   404         $db->expects($this->once())
   407                'il_md_cpr_selections',
   423         $uri->method(
'__toString')->willReturn(
'new link');
   425         $img_uri->method(
'__toString')->willReturn(
'new image link');
   442         $db = $this->createMock(\ilDBInterface::class);
   445         $this->expectException(\ilMDCopyrightException::class);
   446         $repo->updateEntry(21, 
'');
   452             'il_md_cpr_selections',
   457             'il_md_cpr_selections',
   462             'il_md_cpr_selections',
   468         $db->expects($this->once())
   471                'SELECT entry_id FROM il_md_cpr_selections WHERE is_default = 1'   473         $db->expects($this->once())
   474            ->method(
'fetchAssoc')
   475            ->willReturn([
'entry_id' => 5]);
   476         $thrice = $this->exactly(3);
   477         $db->expects($thrice)
   479            ->willReturnCallback(
function (
string $table_name, array $values, array $where) use ($thrice) {
   480                $args = [$table_name, $values, $where];
   482                    'il_md_cpr_selections',
   487                    'il_md_cpr_selections',
   492                    'il_md_cpr_selections',
   496                match ($thrice->getInvocationCount()) {
   497                    1 => $this->assertEquals($exp1, $args),
   498                    2 => $this->assertEquals($exp2, $args),
   499                    3 => $this->assertEquals($exp3, $args)
   505         $repo->reorderEntries(7, 5, 99, 1);
 
if($request_wrapper->has('ui_mainbar')) getURI()
 
__construct()
Constructor setup ILIAS global object  public. 
 
The scope of this class is split ilias-conform URI's into components.