Issues (2149)

unit-tests/MysqldumpTest.php (1 issue)

1
<?php
2
3
use Ifsnop\Mysqldump\Mysqldump;
4
5
class MysqldumpTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
6
{
7
8
    /** @test */
9
    public function tableSpecificWhereConditionsWork()
10
    {
11
        $dump = new Mysqldump('mysql:host=localhost;dbname=test', 'testing', 'testing', array(
12
            'where' => 'defaultWhere'
13
        ));
14
15
        $dump->setTableWheres(array(
16
            'users' => 'date_registered > NOW() - INTERVAL 3 MONTH AND is_deleted=0',
17
            'logs' => 'date_registered > NOW() - INTERVAL 1 DAY',
18
            'posts' => 'active=1'
19
        ));
20
21
        $this->assertEquals(
22
            'date_registered > NOW() - INTERVAL 3 MONTH AND is_deleted=0',
23
            $dump->getTableWhere('users')
24
        );
25
26
        $this->assertEquals(
27
            'defaultWhere',
28
            $dump->getTableWhere('non_overriden_table')
29
        );
30
    }
31
32
    /** @test */
33
    public function tableSpecificLimitsWork()
34
    {
35
        $dump = new Mysqldump('mysql:host=localhost;dbname=test', 'testing', 'testing');
36
37
        $dump->setTableLimits(array(
38
            'users' => 200,
39
            'logs' => 500,
40
            'table_with_invalid_limit' => '41923, 42992'
41
        ));
42
43
        $this->assertEquals(200, $dump->getTableLimit('users'));
44
        $this->assertEquals(500, $dump->getTableLimit('logs'));
45
        $this->assertFalse($dump->getTableLimit('table_with_invalid_limit'));
46
        $this->assertFalse($dump->getTableLimit('table_name_with_no_limit'));
47
    }
48
}
49