Passed
Push — master ( aad828...a88228 )
by Antonio Carlos
03:09 queued 29s
created

ReadIpsFromFilesTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilename() 0 8 2
A setup() 0 15 1
A test_read_file() 0 6 1
1
<?php
2
3
namespace PragmaRX\Firewall\Tests;
4
5
use PragmaRX\Firewall\Vendor\Laravel\Facade as Firewall;
6
7
class ReadIpsFromFilesTest extends TestCase
8
{
9
    private function getFilename()
10
    {
11
        if (!file_exists($dir = __DIR__.'/files')) {
12
            mkdir($dir);
13
        }
14
15
        return "{$dir}/iplist.txt";
16
    }
17
18
    public function setup()
19
    {
20
        parent::setUp();
21
22
        $lines =
23
            "127.0.0.1\n".
24
            "192.168.17.0/24\n".
25
            "127.0.0.1/255.255.255.255\n".
26
            "10.0.0.1-10.0.0.255\n".
27
            "172.17.*.*\n";
28
29
        file_put_contents($this->getFilename(), $lines);
30
31
        $this->setConfig('blacklist', $this->getFilename());
32
    }
33
34
    public function test_read_file()
35
    {
36
        Firewall::blacklist($this->getFilename());
37
38
        $this->assertTrue(Firewall::isBlackListed('10.0.0.9'));
39
    }
40
}
41