Completed
Push — master ( be0721...cced22 )
by Matthew
02:48
created

RepositoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 31
rs 10
1
<?php
2
/**
3
 * This file contains only the ProjectTest class.
4
 */
5
6
namespace Tests\Xtools;
7
8
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
9
use Xtools\Repository;
10
11
/**
12
 * Tests for the Repository class.
13
 */
14
class RepositoryTest extends WebTestCase
15
{
16
    /** @var MockRepository Mock of an abstract Repository class. */
17
    private $stub;
18
19
    protected function setUp()
20
    {
21
        $this->stub = $this->getMockForAbstractClass('Xtools\Repository');
22
    }
23
24
    /**
25
     * Test that the table-name transformations are correct.
26
     */
27
    public function testGetTableName()
28
    {
29
        $client = static::createClient();
30
        $this->container = $client->getContainer();
31
32
        $this->stub->setContainer($this->container);
33
34
        if ($this->container->getParameter('app.is_labs')) {
35
            // When using Labs.
36
            $this->assertEquals('`testwiki_p`.`page`', $this->stub->getTableName('testwiki', 'page'));
37
            $this->assertEquals('`testwiki_p`.`logging_userindex`', $this->stub->getTableName('testwiki', 'logging'));
38
        } else {
39
            // When using wiki databases directly.
40
            $this->assertEquals('`testwiki`.`page`', $this->stub->getTableName('testwiki', 'page'));
41
            $this->assertEquals('`testwiki`.`logging`', $this->stub->getTableName('testwiki', 'logging'));
42
        }
43
    }
44
}
45