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

ReadIpsFromFilesTest::getFilename()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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