Total Complexity | 2 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | trait TestWithSpreadsheet |
||
12 | { |
||
13 | abstract public static function assertTrue($condition, string $message = ''): void; |
||
14 | |||
15 | abstract public static function assertStringStartsWith(string $prefix, string $string, string $message = ''): void; |
||
16 | |||
17 | abstract public static function assertFileExists(string $filename, string $message = ''): void; |
||
18 | |||
19 | private function readExport(string $hostname, string $url): Spreadsheet |
||
20 | { |
||
21 | $baseUrl = 'https://' . $hostname . '/data/export/'; |
||
22 | |||
23 | self::assertStringStartsWith($baseUrl, $url, 'must be absolute URL'); |
||
24 | |||
25 | // Make sure the XLSX file was generated on disk |
||
26 | $path = 'htdocs/data/export/' . str_replace($baseUrl, '', $url); |
||
27 | self::assertFileExists($path, 'exported file must exist on disk'); |
||
28 | |||
29 | return $this->readSpreadsheet($path); |
||
30 | } |
||
31 | |||
32 | private function readSpreadsheet(string $filename): Spreadsheet |
||
46 | } |
||
47 | } |
||
48 |