ILIAS
trunk Revision v11.0_alpha-3011-gc6b235a2e85
◀ ilDoc Overview
PageReadingTimeTest.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\ContentPage
;
22
23
use
ILIAS\ContentPage\PageMetrics\ValueObject\PageReadingTime
;
24
use PHPUnit\Framework\TestCase;
25
use TypeError;
26
use stdClass;
27
use PHPUnit\Framework\Attributes\DataProvider;
28
29
class
PageReadingTimeTest
extends
TestCase
30
{
31
public
static
function
mixedReadingTypesProvider
(): array
32
{
33
return
[
34
'Float Type'
=> [4.0],
35
'String Type'
=> [
'4'
],
36
'Array Type'
=> [[4]],
37
'Object Type'
=> [
new
stdClass()],
38
'Boolean Type'
=> [
false
],
39
'Null Type'
=> [
null
],
40
'Ressource Type'
=> [fopen(
'php://temp'
,
'rb'
)]
41
];
42
}
43
44
#[DataProvider('mixedReadingTypesProvider')]
45
public
function
testPageReadingTimeValueThrowsExceptionWhenConstructedWithInvalidTypes
(mixed $mixedType): void
46
{
47
$this->expectException(TypeError::class);
48
49
$readingTime =
new
PageReadingTime
($mixedType);
50
}
51
52
public
function
testRawReadingTimeCanBeRetrievedFromValueObject
(): void
53
{
54
$readingTime =
new
PageReadingTime
(5);
55
$this->assertSame(5, $readingTime->minutes());
56
}
57
}
ILIAS\ContentPage\PageMetrics\ValueObject\PageReadingTime
Definition:
PageReadingTime.php:26
ILIAS\ContentPage\PageReadingTimeTest
Definition:
PageReadingTimeTest.php:30
ILIAS\ContentPage\PageReadingTimeTest\testRawReadingTimeCanBeRetrievedFromValueObject
testRawReadingTimeCanBeRetrievedFromValueObject()
Definition:
PageReadingTimeTest.php:52
ILIAS\ContentPage\PageReadingTimeTest\mixedReadingTypesProvider
static mixedReadingTypesProvider()
Definition:
PageReadingTimeTest.php:31
ILIAS\ContentPage\PageReadingTimeTest\testPageReadingTimeValueThrowsExceptionWhenConstructedWithInvalidTypes
testPageReadingTimeValueThrowsExceptionWhenConstructedWithInvalidTypes(mixed $mixedType)
Definition:
PageReadingTimeTest.php:45
ILIAS\ContentPage
components
ILIAS
ContentPage
tests
PageReadingTimeTest.php
Generated on Sat Oct 18 2025 23:02:50 for ILIAS by
1.9.4 (using
Doxyfile
)