ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CopyrightDataTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestCase;
26
27class CopyrightDataTest extends TestCase
28{
29 protected function getMockURI(): URI
30 {
31 return $this->createMock(URI::class);
32 }
33
34 protected function getData(?URI $image_link, string $image_file): CopyrightData
35 {
36 return new CopyrightData(
37 'name',
38 $this->getMockURI(),
39 $image_link,
40 $image_file,
41 'alt',
42 false
43 );
44 }
45
46 public function testImage(): void
47 {
48 $uri = $this->getMockURI();
49
50 $data_without_image = $this->getData(null, '');
51 $data_with_file_image = $this->getData(null, 'file identifier');
52 $data_with_link_image = $this->getData($uri, '');
53
54 $this->assertSame('', $data_without_image->imageFile());
55 $this->assertNull($data_without_image->imageLink());
56
57 $this->assertSame('file identifier', $data_with_file_image->imageFile());
58 $this->assertNull($data_with_file_image->imageLink());
59
60 $this->assertSame('', $data_with_link_image->imageFile());
61 $this->assertSame($uri, $data_with_link_image->imageLink());
62 }
63
64 public function testHasImage(): void
65 {
66 $data_without_image = $this->getData(null, '');
67 $data_with_file_image = $this->getData(null, 'file identifier');
68 $data_with_link_image = $this->getData($this->getMockURI(), '');
69
70 $this->assertFalse($data_without_image->hasImage());
71 $this->assertTrue($data_with_file_image->hasImage());
72 $this->assertTrue($data_with_link_image->hasImage());
73 }
74
75 public function testIsImageLink(): void
76 {
77 $data_without_image = $this->getData(null, '');
78 $data_with_file_image = $this->getData(null, 'file identifier');
79 $data_with_link_image = $this->getData($this->getMockURI(), '');
80
81 $this->assertFalse($data_without_image->isImageLink());
82 $this->assertFalse($data_with_file_image->isImageLink());
83 $this->assertTrue($data_with_link_image->isImageLink());
84 }
85}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
getData(?URI $image_link, string $image_file)