Passed
Pull Request — master (#172)
by David
02:16
created

StaticPartialQueryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetMagicQuery() 0 5 1
A testGetParameters() 0 5 1
A testRegisterDataLoader() 0 5 1
1
<?php
2
3
namespace TheCodingMachine\TDBM\QueryFactory\SmartEagerLoad\Query;
4
5
use Doctrine\DBAL\Connection;
6
use Mouf\Database\MagicQuery;
7
use PHPUnit\Framework\TestCase;
8
use TheCodingMachine\TDBM\QueryFactory\SmartEagerLoad\StorageNode;
9
use TheCodingMachine\TDBM\TDBMException;
10
11
class StaticPartialQueryTest extends TestCase
12
{
13
    public function testRegisterDataLoader()
14
    {
15
        $query = new StaticPartialQuery('FROM users', ['foo'=>42], ['users'], $this->createMock(StorageNode::class), new MagicQuery());
16
        $this->expectException(TDBMException::class);
17
        $query->registerDataLoader($this->createMock(Connection::class));
18
    }
19
20
    public function testGetMagicQuery()
21
    {
22
        $magicQuery = new MagicQuery();
23
        $query = new StaticPartialQuery('FROM users', ['foo'=>42], ['users'], $this->createMock(StorageNode::class), $magicQuery);
24
        $this->assertSame($magicQuery, $query->getMagicQuery());
25
    }
26
27
    public function testGetParameters()
28
    {
29
        $magicQuery = new MagicQuery();
30
        $query = new StaticPartialQuery('FROM users', ['foo'=>42], ['users'], $this->createMock(StorageNode::class), $magicQuery);
31
        $this->assertSame(['foo'=>42], $query->getParameters());
32
    }
33
}
34