Passed
Push — master ( 3e0ba1...df5150 )
by El
20:25 queued 10:25
created

tst/privatebinWithDb.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
require_once 'privatebin.php';
3
4
class privatebinWithDbTest extends privatebinTest
5
{
6
    private $_options = array(
7
        'dsn' => 'sqlite:../data/tst.sq3',
8
        'usr' => null,
9
        'pwd' => null,
10
        'opt' => array(
11
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
12
            PDO::ATTR_PERSISTENT => true
13
        ),
14
    );
15
16
    public function setUp()
17
    {
18
        /* Setup Routine */
19
        $this->_model = privatebin_db::getInstance($this->_options);
20
        serversalt::setPath(PATH . 'data');
21
        $this->reset();
22
    }
23
24
    public function tearDown()
25
    {
26
        /* Tear Down Routine */
27
        parent::tearDown();
28
        @unlink('../data/tst.sq3');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
29
    }
30
31
    public function reset()
32
    {
33
        parent::reset();
34
        // but then inject a db config
35
        $options = parse_ini_file(CONF, true);
36
        $options['model'] = array(
37
            'class' => 'privatebin_db',
38
        );
39
        $options['model_options'] = $this->_options;
40
        helper::confBackup();
41
        helper::createIniFile(CONF, $options);
42
    }
43
}
44