Completed
Push — develop ( b85182...537c08 )
by Narcotic
02:54
created

MongoCredentialsProviderTest::testMongoHandling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
/**
3
 * test mongocredential provider
4
 */
5
6
namespace Graviton\ImportExportTest\Util;
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