ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PageReadingTimeTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\ContentPage;
22
24use PHPUnit\Framework\TestCase;
25use TypeError;
26use stdClass;
27use PHPUnit\Framework\Attributes\DataProvider;
28
29class 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')]
46 {
47 $this->expectException(TypeError::class);
48
49 $readingTime = new PageReadingTime($mixedType);
50 }
51
53 {
54 $readingTime = new PageReadingTime(5);
55 $this->assertSame(5, $readingTime->minutes());
56 }
57}
testPageReadingTimeValueThrowsExceptionWhenConstructedWithInvalidTypes(mixed $mixedType)