Completed
Push — master ( ef5eaa...6d70d2 )
by Lars
03:21 queued 30s
created

ConfigTest53::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
use idiorm\orm\ORM;
4
5
class ConfigTest53 extends PHPUnit_Framework_TestCase {
6
7
    public function setUp() {
8
        // Enable logging
9
        ORM::configure('logging', true);
10
11
        // Set up the dummy database connection
12
        $db = new MockPDO('sqlite::memory:');
13
        ORM::set_db($db);
14
15
        ORM::configure('id_column', 'primary_key');
16
    }
17
18
    public function tearDown() {
19
        ORM::configure('logging', false);
20
        ORM::set_db(null);
21
22
        ORM::configure('id_column', 'id');
23
    }
24
25
    public function testLoggerCallback() {
26
        ORM::configure('logger', function($log_string) {
27
            return $log_string;
28
        });
29
        $function = ORM::get_config('logger');
30
        $this->assertTrue(is_callable($function));
31
32
        $log_string = "UPDATE `widget` SET `added` = NOW() WHERE `id` = '1'";
33
        $this->assertEquals($log_string, $function($log_string));
34
35
        ORM::configure('logger', null);
36
    }
37
38
}