Completed
Push — master ( 9de5b8...ddab96 )
by Matteo
03:46
created

BridgeTestCase::loadFixtures()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
use Mattbit\MysqlCompat\Bridge;
4
use Mattbit\MysqlCompat\Manager;
5
6
class BridgeTestCase extends FunctionalTestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    /**
9
     * @var Bridge
10
     */
11
    protected $bridge;
12
13
    /**
14
     * @var \PDO
15
     */
16
    protected $db;
17
18
    public function setUp()
19
    {
20
        $manager = new Manager(new \Mattbit\MysqlCompat\ConnectionFactory());
21
        $this->bridge = new Bridge($manager);
22
23
        $this->bridge->connect($this->config['dbhost'], $this->config['dbuser'], $this->config['dbpass']);
24
        $this->bridge->selectDb($this->config['dbname']);
25
26
        $this->loadFixtures();
27
    }
28
29
    protected function loadFixtures()
30
    {
31
        $dbname = $this->config['dbname'];
32
        $dbhost = $this->config['dbhost'];
33
        $dbuser = $this->config['dbuser'];
34
        $dbpass = $this->config['dbpass'];
35
36
        $this->db = new PDO("mysql:dbname=$dbname;host=$dbhost", $dbuser, $dbpass);
37
        $sql = file_get_contents(__DIR__.'/fixtures.sql');
38
        $this->db->query($sql);
39
    }
40
}