Completed
Push — master ( 9fccc1...f183dd )
by
unknown
03:01
created

RepositoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 31
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testGetTableName() 0 17 2
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');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...s('Xtools\\Repository') of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<Tests\Xtools\MockRepository> of property $stub.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
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();
0 ignored issues
show
Bug introduced by
The property container does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
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('`page`', $this->stub->getTableName('testwiki', 'page'));
41
            $this->assertEquals('`logging`', $this->stub->getTableName('testwiki', 'logging'));
42
        }
43
    }
44
}
45