Completed
Push — master ( a79865...f1a019 )
by Adrien
09:59
created

SampleTest::testSample()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Helper;
4
5
use PhpOffice\PhpSpreadsheet\Helper\Sample;
6
use PHPUnit\Framework\TestCase;
7
8
class SampleTest extends TestCase
9
{
10
    /**
11
     * @runInSeparateProcess
12
     * @preserveGlobalState disabled
13
     * @dataProvider providerSample
14
     *
15
     * @param mixed $sample
16
     */
17
    public function testSample($sample)
18
    {
19
        // Suppress output to console
20
        $this->setOutputCallback(function () {
21
        });
22
23
        require $sample;
24
25
        self::assertTrue(true);
26
    }
27
28
    public function providerSample()
29
    {
30
        $skipped = [
31
            'Chart/32_Chart_read_write_PDF.php', // Unfortunately JpGraph is not up to date for latest PHP and raise many warnings
32
            'Chart/32_Chart_read_write_HTML.php', // idem
33
        ];
34
35
        // Unfortunately some tests are too long be ran with code-coverage
36
        // analysis on Travis, so we need to exclude them
37
        global $argv;
38
        if (in_array('--coverage-clover', $argv)) {
39
            $tooLongToBeCovered = [
40
                'Basic/06_Largescale.php',
41
                'Basic/13_CalculationCyclicFormulae.php',
42
            ];
43
            $skipped = array_merge($skipped, $tooLongToBeCovered);
44
        }
45
46
        $helper = new Sample();
47
        $result = [];
48
        foreach ($helper->getSamples() as $samples) {
49
            foreach ($samples as $sample) {
0 ignored issues
show
Bug introduced by
The expression $samples of type string is not traversable.
Loading history...
50
                if (!in_array($sample, $skipped)) {
51
                    $file = '../samples/' . $sample;
52
                    $result[] = [$file];
53
                }
54
            }
55
        }
56
57
        return $result;
58
    }
59
}
60