ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
PageReadingTimeTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\ContentPage;
22 
25 use TypeError;
26 use stdClass;
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')]
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null