Passed
Pull Request — master (#14)
by Timon
02:48
created

ConnectionTest::testConnect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Connection;
5
6
use Mockery;
7
use Mockery\MockInterface;
8
use TBolier\RethinkQL\Connection\ConnectionInterface;
9
use TBolier\RethinkQL\Connection\OptionsInterface;
10
use TBolier\RethinkQL\IntegrationTest\BaseTestCase;
11
use TBolier\RethinkQL\Response\ResponseInterface;
12
use TBolier\RethinkQL\Types\Query\QueryType;
13
14
class ConnectionTest extends BaseTestCase
15
{
16
    /**
17
     * @var MockInterface
18
     */
19
    private $optionsMock;
20
21
    public function setUp()
22
    {
23
        parent::setUp();
24
25
        $this->optionsMock = Mockery::mock(OptionsInterface::class);
26
    }
27
28
    /**
29
     * @throws \Exception
30
     */
31
    public function testConnect()
32
    {
33
        /** @var ConnectionInterface $connection */
34
        $connection = $this->createConnection('phpunit_default')->connect();
35
        $result = $connection->expr('foo');
36
37
        $this->assertInstanceOf(ResponseInterface::class, $result);
38
        $this->assertEquals('foo', $result->getData()[0]);
39
    }
40
41
    /**
42
     * @throws \Exception
43
     */
44
    public function testServer()
45
    {
46
        /** @var ConnectionInterface $connection */
47
        $res = $this->createConnection('phpunit_default')->connect()->server();
48
49
        $this->assertEquals(QueryType::SERVER_INFO, $res->getType());
50
        $this->assertInternalType('string', $res->getData()[0]['name']);
51
    }
52
}
53