Completed
Push — develop ( 2a6d35...6e507e )
by Bastian
12s
created

MongoCredentialsProviderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMongoHandling() 0 10 1
A fromInputProvider() 0 9 1
1
<?php
2
/**
3
 * test mongocredential provider
4
 */
5
6
namespace Graviton\ImportExport\Tests\Command;
7
8
use Graviton\ImportExport\Util\MongoCredentialsProvider;
9
10
/**
11
 * @author   List of contributors <https://github.com/libgraviton/import-export/graphs/contributors>
12
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
13
 * @link     http://swisscom.ch
14
 */
15
class MongoCredentialsProviderTest extends \PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * check fromInput method
19
     *
20
     * @dataProvider fromInputProvider
21
     *
22
     * @param string $uri connection string
23
     * @param string $db  expected db name
24
     *
25
     * @return void
26
     */
27
    public function testMongoHandling($uri, $db)
28
    {
29
        $inputMock = $this->createMock('Symfony\Component\Console\Input\InputInterface');
30
        $inputMock->expects($this->once())
31
            ->method('getOption')
32
            ->with('mongodb')
33
            ->will($this->returnValue($uri));
34
35
        $this->assertEquals(['uri' => $uri, 'db' => $db], MongoCredentialsProvider::fromInput($inputMock));
36
    }
37
38
    /**
39
     * @return array
40
     */
41
    public function fromInputProvider()
42
    {
43
        return [
44
            ['mongodb://localhost:27017', 'db'],
45
            ['mongodb://localhost:27017/', 'db'],
46
            ['mongodb://localhost:27017/foo', 'foo'],
47
            ['mongodb://localhost:27017/foo?db=bar', 'bar']
48
        ];
49
    }
50
}
51