ILIAS  release_8 Revision v8.24
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;
27
32class PageReadingTimeTest extends TestCase
33{
34 public function mixedReadingTypesProvider(): array
35 {
36 return [
37 'Float Type' => [4.0],
38 'String Type' => ['4'],
39 'Array Type' => [[4]],
40 'Object Type' => [new stdClass()],
41 'Boolean Type' => [false],
42 'Null Type' => [null],
43 'Ressource Type' => [fopen('php://temp', 'rb')]
44 ];
45 }
46
52 {
53 $this->expectException(TypeError::class);
54
55 $readingTime = new PageReadingTime($mixedType);
56 }
57
59 {
60 $readingTime = new PageReadingTime(5);
61 $this->assertSame(5, $readingTime->minutes());
62 }
63}
testPageReadingTimeValueThrowsExceptionWhenConstructedWithInvalidTypes($mixedType)