ConfigurationTest::setUp()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 37
rs 8.8571
c 2
b 0
f 0
cc 1
eloc 31
nc 1
nop 0
1
<?php
2
3
namespace OpCacheGUITest\OpCache;
4
5
use OpCacheGUI\Format\Byte;
6
use OpCacheGUI\OpCache\Configuration;
7
use PHPUnit\Framework\TestCase;
8
9
class ConfigurationTest extends TestCase
10
{
11
    protected $configData;
12
13
    protected function setUp()
14
    {
15
        $this->configData = [
16
            'directives' => [
17
                'opcache.enable'                  => true,
18
                'opcache.enable_cli'              => false,
19
                'opcache.use_cwd'                 => true,
20
                'opcache.validate_timestamps'     => true,
21
                'opcache.dups_fix'                => false,
22
                'opcache.revalidate_path'         => false,
23
                'opcache.log_verbosity_level'     => 1,
24
                'opcache.memory_consumption'      => 134217728,
25
                'opcache.interned_strings_buffer' => 8,
26
                'opcache.max_accelerated_files'   => 4000,
27
                'opcache.max_wasted_percentage'   => 0.05,
28
                'opcache.consistency_checks'      => 0,
29
                'opcache.force_restart_timeout'   => 180,
30
                'opcache.revalidate_freq'         => 60,
31
                'opcache.preferred_memory_model'  => '',
32
                'opcache.blacklist_filename'      => '',
33
                'opcache.max_file_size'           => 0,
34
                'opcache.error_log'               => '',
35
                'opcache.protect_memory'          => false,
36
                'opcache.save_comments'           => false,
37
                'opcache.fast_shutdown'           => true,
38
                'opcache.enable_file_override'    => true,
39
                'opcache.optimization_level'      => 2147483647,
40
            ],
41
            'version' => [
42
                'version'              => '7.0.2-dev',
43
                'opcache_product_name' => 'Zend OPcache',
44
            ],
45
            'blacklist' => [
46
                '/var/www/vhosts/OpCacheGUI/src/OpCacheGUI/Presentation/Html.php'
47
            ],
48
        ];
49
    }
50
51
    /**
52
     * @covers OpCacheGUI\OpCache\Configuration::__construct
53
     * @covers OpCacheGUI\OpCache\Configuration::getIniDirectives
54
     */
55
    public function testGetIniDirectives()
56
    {
57
        $formatter = $this->createMock(Byte::class);
58
        $formatter->method('format')->willReturn('1KB');
59
60
        $config = new Configuration($formatter, $this->configData);
61
62
        $this->configData['directives']['opcache.memory_consumption'] = '1KB';
63
64
        $this->assertSame($this->configData['directives'], $config->getIniDirectives());
65
    }
66
67
    /**
68
     * @covers OpCacheGUI\OpCache\Configuration::__construct
69
     * @covers OpCacheGUI\OpCache\Configuration::getBlackList
70
     */
71
    public function testGetBlackList()
72
    {
73
        $config = new Configuration($this->createMock(Byte::class), $this->configData);
74
75
        $this->assertSame($this->configData['blacklist'], $config->getBlackList());
76
    }
77
}
78