summaryrefslogtreecommitdiff
path: root/test/ConfigTest53.php
blob: ef8af778a70d574ffe1e9dafd397799209975698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

class ConfigTest53 extends PHPUnit_Framework_TestCase {

    public function setUp() {
        // Enable logging
        ORM::configure('logging', true);

        // Set up the dummy database connection
        $db = new MockPDO('sqlite::memory:');
        ORM::set_db($db);

        ORM::configure('id_column', 'primary_key');
    }

    public function tearDown() {
        ORM::configure('logging', false);
        ORM::set_db(null);

        ORM::configure('id_column', 'id');
    }

    public function testLoggerCallback() {
        ORM::configure('logger', function($log_string) {
            return $log_string;
        });
        $function = ORM::get_config('logger');
        $this->assertTrue(is_callable($function));

        $log_string = "UPDATE `widget` SET `added` = NOW() WHERE `id` = '1'";
        $this->assertEquals($log_string, $function($log_string));

        ORM::configure('logger', null);
    }

}