ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
StringTransformationTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Tests\Refinery\URI;
22 
23 use ILIAS\Data\URI;
27 
28 class StringTransformationTest extends TestCase
29 {
31 
32  protected function setUp(): void
33  {
34  $this->transformation = new StringTransformation();
35  }
36 
37  public function testSimpleUri(): void
38  {
39  $uri = new URI('http://ilias.de');
40  $transformedValue = $this->transformation->transform($uri);
41 
42  $this->assertEquals('http://ilias.de', $transformedValue);
43  }
44 
45  public function testUriWithPath(): void
46  {
47  $uri = new URI('http://ilias.de/with/path');
48  $transformedValue = $this->transformation->transform($uri);
49 
50  $this->assertEquals('http://ilias.de/with/path', $transformedValue);
51  }
52 
53  public function testUriWithFragment(): void
54  {
55  $uri = new URI('http://ilias.de/test.php#title');
56  $transformedValue = $this->transformation->transform($uri);
57 
58  $this->assertEquals('http://ilias.de/test.php#title', $transformedValue);
59  }
60 
61  public function testSimpleUriWithQueryParameter(): void
62  {
63  $uri = new URI('http://ilias.de?test=something&further=1');
64  $transformedValue = $this->transformation->transform($uri);
65 
66  $this->assertEquals('http://ilias.de?test=something&further=1', $transformedValue);
67  }
68 
69  public function testUriWithQueryPathAndParameter(): void
70  {
71  $uri = new URI('http://ilias.de/with/path?test=something&further=1');
72  $transformedValue = $this->transformation->transform($uri);
73 
74  $this->assertEquals('http://ilias.de/with/path?test=something&further=1', $transformedValue);
75  }
76 
77  public function testTransformNotURIObjectFails(): void
78  {
79  $this->expectException(ConstraintViolationException::class);
80  $transformedValue = $this->transformation->transform('http://ilias.de');
81 
82  $this->assertEquals('http://ilias.de', $transformedValue);
83  }
84 }