LocalFileStorageTest::testXlsx()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Mathielen\ImportEngine\Storage;
3
4
use Mathielen\ImportEngine\Storage\Format\CsvFormat;
5
use Mathielen\ImportEngine\Storage\Format\ExcelFormat;
6
7
class LocalFileStorageTest extends \PHPUnit_Framework_TestCase
8
{
9
10 View Code Duplication
    public function testCsv()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
    {
12
        $format = new CsvFormat(';');
13
        $localFile = new LocalFileStorage(new \SplFileObject(__DIR__ . '/../../../../metadata/testfiles/flatdata.csv'), $format);
14
        $reader = $localFile->reader();
15
16
        $info = $localFile->info();
17
        $this->assertEquals(new StorageInfo(array(
18
            'name' => 'flatdata.csv',
19
            'format' => $format,
20
            'size' => 32,
21
            'count' => 1,
22
            'hash' => '4f0e1e99eb12d94dc527fedce9eb58d8'
23
        )), $info);
24
25
        $headers = $reader->getColumnHeaders();
26
        $this->assertEquals(2, count($headers));
27
    }
28
29 View Code Duplication
    public function testXls()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        $format = new ExcelFormat();
32
        $localFile = new LocalFileStorage(new \SplFileObject(__DIR__ . '/../../../../metadata/testfiles/flatdata-excel.xls'), $format);
33
        $reader = $localFile->reader();
34
35
        $info = $localFile->info();
36
        $this->assertEquals(new StorageInfo(array(
37
            'name' => 'flatdata-excel.xls',
38
            'format' => $format,
39
            'size' => 23552,
40
            'count' => 1,
41
            'hash' => '3dbea55520f59ebdd08b6ad85ae95005'
42
        )), $info);
43
44
        $headers = $reader->getColumnHeaders();
45
        $this->assertEquals(2, count($headers));
46
    }
47
48 View Code Duplication
    public function testXlsx()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $format = new ExcelFormat();
51
        $localFile = new LocalFileStorage(new \SplFileObject(__DIR__ . '/../../../../metadata/testfiles/flatdata-excel-xml.xlsx'), $format);
52
        $reader = $localFile->reader();
53
54
        $info = $localFile->info();
55
        $this->assertEquals(new StorageInfo(array(
56
            'name' => 'flatdata-excel-xml.xlsx',
57
            'format' => $format,
58
            'size' => 8895,
59
            'count' => 2,
60
            'hash' => 'b297aa9bbc37f9cd51d8472498772474'
61
        )), $info);
62
63
        $headers = $reader->getColumnHeaders();
64
        $this->assertEquals(2, count($headers));
65
    }
66
}
67