Completed
Push — develop ( de57bf...976711 )
by Adrien
17:31
created

SettingsTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests;
4
5
class SettingsTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $prevValue;
11
12
    public function setUp()
13
    {
14
        $this->prevValue = libxml_disable_entity_loader();
0 ignored issues
show
Documentation Bug introduced by
The property $prevValue was declared of type string, but libxml_disable_entity_loader() is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
15
        libxml_disable_entity_loader(false); // Enable entity loader
16
    }
17
18
    protected function tearDown()
19
    {
20
        libxml_disable_entity_loader($this->prevValue);
21
    }
22
23
    public function testGetXMLSettings()
24
    {
25
        $result = \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions();
26
        $this->assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR) & $result));
27
        $this->assertFalse(libxml_disable_entity_loader());
28
    }
29
30
    public function testSetXMLSettings()
31
    {
32
        \PhpOffice\PhpSpreadsheet\Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID);
33
        $result = \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions();
34
        $this->assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID) & $result));
35
        $this->assertFalse(libxml_disable_entity_loader());
36
    }
37
}
38