Completed
Push — master ( cb8d9e...ee4360 )
by Stefan
03:12
created

SheetTest::setUpBeforeClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
class SheetTest extends PHPUnit_Framework_TestCase
4
{
5
    /**
6
     * @var OneSheet\Sheet
7
     */
8
    protected static $sheet;
9
10
    /**
11
     * @var string
12
     */
13
    private static $path;
14
15
    public static function setUpBeforeClass()
16
    {
17
        self::$sheet = new \OneSheet\Sheet('A2');
18
        self::$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'sheet1.xml';
19
    }
20
21
    public function testConstructor()
22
    {
23
        $this->assertInstanceOf('OneSheet\Sheet', new OneSheet\Sheet('B2'));
24
    }
25
26
    public function testSheetFilePath()
27
    {
28
        $this->assertEquals(
29
            self::$path, self::$sheet->sheetFilePath()
30
        );
31
    }
32
33
    public function testAddStyle()
34
    {
35
        $this->assertGreaterThan(1, \OneSheet\StyleHelper::buildStyle(new OneSheet\Style()));
36
    }
37
38
    public function testAddRows()
39
    {
40
        $number = time();
41
        $string = uniqid();
42
43
        self::$sheet->addRows(array(array($number)), 1);
44
        $style = new \OneSheet\Style();
45
        self::$sheet->addRows(array(array($string)), $style);
46
        $xml = file_get_contents(self::$path);
47
48
        $this->assertEquals(1, preg_match('~'. $number . '.*' . $string . '~', $xml, $match));
49
    }
50
51
52
53
}
54