Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SqlTest.php « Core « Integration « PHPUnit « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 47a3c23f181eb9ca1ace1da7cba6aee929bbabc1 (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
37
38
39
40
41
42
43
44
45
46
<?php
use Piwik\Db;

/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @group Core
 */
class Core_SqlTest extends DatabaseTestCase
{
    public function setUp()
    {
        parent::setUp();

        // create two myisam tables
        Db::exec("CREATE TABLE table1 (a INT) ENGINE=MYISAM");
        Db::exec("CREATE TABLE table2 (b INT) ENGINE=MYISAM");

        // create two innodb tables
        Db::exec("CREATE TABLE table3 (c INT) ENGINE=InnoDB");
        Db::exec("CREATE TABLE table4 (d INT) ENGINE=InnoDB");
    }

    public function tearDown()
    {
        parent::tearDown();
    }

    /**
     * @group Core
     */
    public function testOptimize()
    {
        // make sure optimizing myisam tables works
        $this->assertTrue(Db::optimizeTables(array('table1', 'table2')) !== false);

        // make sure optimizing both myisam & innodb results in optimizations
        $this->assertTrue(Db::optimizeTables(array('table1', 'table2', 'table3', 'table4')) !== false);

        // make sure innodb tables are skipped
        $this->assertTrue(Db::optimizeTables(array('table3', 'table4')) === false);
    }
}