SampleTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Helper;
  3. use PhpOffice\PhpSpreadsheet\Helper\Sample;
  4. use PHPUnit\Framework\TestCase;
  5. class SampleTest extends TestCase
  6. {
  7. /**
  8. * @runInSeparateProcess
  9. *
  10. * @preserveGlobalState disabled
  11. *
  12. * @dataProvider providerSample
  13. */
  14. public function testSample(string $sample): void
  15. {
  16. // Suppress output to console
  17. $this->setOutputCallback(function (): void {
  18. });
  19. require $sample;
  20. self::assertTrue(true);
  21. }
  22. public function providerSample(): array
  23. {
  24. $skipped = [
  25. ];
  26. // Unfortunately some tests are too long to run with code-coverage
  27. // analysis on GitHub Actions, so we need to exclude them
  28. global $argv;
  29. if (in_array('--coverage-clover', $argv)) {
  30. $tooLongToBeCovered = [
  31. 'Basic/06_Largescale.php',
  32. 'Basic/13_CalculationCyclicFormulae.php',
  33. ];
  34. $skipped = array_merge($skipped, $tooLongToBeCovered);
  35. }
  36. $helper = new Sample();
  37. $result = [];
  38. foreach ($helper->getSamples() as $samples) {
  39. foreach ($samples as $sample) {
  40. if (!in_array($sample, $skipped)) {
  41. $file = 'samples/' . $sample;
  42. $result[$sample] = [$file];
  43. }
  44. }
  45. }
  46. return $result;
  47. }
  48. }