aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/visitor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/front/controller/visitor')
-rw-r--r--tests/front/controller/visitor/DailyControllerTest.php27
-rw-r--r--tests/front/controller/visitor/FrontControllerMockHelper.php10
2 files changed, 19 insertions, 18 deletions
diff --git a/tests/front/controller/visitor/DailyControllerTest.php b/tests/front/controller/visitor/DailyControllerTest.php
index 872420fd..b802c62c 100644
--- a/tests/front/controller/visitor/DailyControllerTest.php
+++ b/tests/front/controller/visitor/DailyControllerTest.php
@@ -57,20 +57,20 @@ class DailyControllerTest extends TestCase
57 (new Bookmark()) 57 (new Bookmark())
58 ->setId(1) 58 ->setId(1)
59 ->setUrl('http://url.tld') 59 ->setUrl('http://url.tld')
60 ->setTitle(static::generateContent(50)) 60 ->setTitle(static::generateString(50))
61 ->setDescription(static::generateContent(500)) 61 ->setDescription(static::generateString(500))
62 , 62 ,
63 (new Bookmark()) 63 (new Bookmark())
64 ->setId(2) 64 ->setId(2)
65 ->setUrl('http://url2.tld') 65 ->setUrl('http://url2.tld')
66 ->setTitle(static::generateContent(50)) 66 ->setTitle(static::generateString(50))
67 ->setDescription(static::generateContent(500)) 67 ->setDescription(static::generateString(500))
68 , 68 ,
69 (new Bookmark()) 69 (new Bookmark())
70 ->setId(3) 70 ->setId(3)
71 ->setUrl('http://url3.tld') 71 ->setUrl('http://url3.tld')
72 ->setTitle(static::generateContent(50)) 72 ->setTitle(static::generateString(50))
73 ->setDescription(static::generateContent(500)) 73 ->setDescription(static::generateString(500))
74 , 74 ,
75 ]; 75 ];
76 }) 76 })
@@ -194,8 +194,8 @@ class DailyControllerTest extends TestCase
194 (new Bookmark()) 194 (new Bookmark())
195 ->setId(1) 195 ->setId(1)
196 ->setUrl('http://url.tld') 196 ->setUrl('http://url.tld')
197 ->setTitle(static::generateContent(50)) 197 ->setTitle(static::generateString(50))
198 ->setDescription(static::generateContent(500)) 198 ->setDescription(static::generateString(500))
199 , 199 ,
200 ]; 200 ];
201 }) 201 })
@@ -267,8 +267,8 @@ class DailyControllerTest extends TestCase
267 (new Bookmark()) 267 (new Bookmark())
268 ->setId(2) 268 ->setId(2)
269 ->setUrl('http://url.tld') 269 ->setUrl('http://url.tld')
270 ->setTitle(static::generateContent(50)) 270 ->setTitle(static::generateString(50))
271 ->setDescription(static::generateContent(5000)) 271 ->setDescription(static::generateString(5000))
272 , 272 ,
273 (new Bookmark())->setId(3)->setUrl('http://url.tld')->setTitle('title'), 273 (new Bookmark())->setId(3)->setUrl('http://url.tld')->setTitle('title'),
274 (new Bookmark())->setId(4)->setUrl('http://url.tld')->setTitle('title'), 274 (new Bookmark())->setId(4)->setUrl('http://url.tld')->setTitle('title'),
@@ -473,11 +473,4 @@ class DailyControllerTest extends TestCase
473 static::assertFalse($assignedVariables['hide_timestamps']); 473 static::assertFalse($assignedVariables['hide_timestamps']);
474 static::assertCount(0, $assignedVariables['days']); 474 static::assertCount(0, $assignedVariables['days']);
475 } 475 }
476
477 protected static function generateContent(int $length): string
478 {
479 // bin2hex(random_bytes) generates string twice as long as given parameter
480 $length = (int) ceil($length / 2);
481 return bin2hex(random_bytes($length));
482 }
483} 476}
diff --git a/tests/front/controller/visitor/FrontControllerMockHelper.php b/tests/front/controller/visitor/FrontControllerMockHelper.php
index d16b6949..fecd0c82 100644
--- a/tests/front/controller/visitor/FrontControllerMockHelper.php
+++ b/tests/front/controller/visitor/FrontControllerMockHelper.php
@@ -42,7 +42,7 @@ trait FrontControllerMockHelper
42 // Config 42 // Config
43 $this->container->conf = $this->createMock(ConfigManager::class); 43 $this->container->conf = $this->createMock(ConfigManager::class);
44 $this->container->conf->method('get')->willReturnCallback(function (string $parameter, $default) { 44 $this->container->conf->method('get')->willReturnCallback(function (string $parameter, $default) {
45 return $default; 45 return $default === null ? $parameter : $default;
46 }); 46 });
47 47
48 // PageBuilder 48 // PageBuilder
@@ -101,6 +101,14 @@ trait FrontControllerMockHelper
101 ; 101 ;
102 } 102 }
103 103
104 protected static function generateString(int $length): string
105 {
106 // bin2hex(random_bytes) generates string twice as long as given parameter
107 $length = (int) ceil($length / 2);
108
109 return bin2hex(random_bytes($length));
110 }
111
104 /** 112 /**
105 * Force to be used in PHPUnit context. 113 * Force to be used in PHPUnit context.
106 */ 114 */