Completed
Pull Request — master (#22)
by
unknown
04:12 queued 02:09
created

SyncTest::getMockConnector()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
namespace Communibase;
3
4
use GuzzleHttp\Promise\FulfilledPromise;
5
6
/**
7
 * @package Communibase
8
 * @author Kingsquare ([email protected])
9
 * @copyright Copyright (c) Kingsquare BV (http://www.kingsquare.nl)
10
 */
11
class SyncTest extends \PHPUnit_Framework_TestCase
12
{
13
14
    /**
15
     * @test
16
     */
17
    public function testSync()
18
    {
19
        $result = $this->getMockConnector()->getById('Person', $this->getMockConnector()->generateId());
20
        $this->assertSame([], $result);
21
    }
22
23
    /**
24
     * @test
25
     */
26
    public function testAsync()
27
    {
28
        $this->getMockConnector()->getByIdAsync('Person', $this->getMockConnector()->generateId())->then(function ($result) {
29
            $this->assertSame([], $result);
30
        })->wait(); // wait to complete the test ;-)
31
    }
32
33
    /**
34
     * @return \Communibase\Connector
35
     */
36
    protected function getMockConnector() {
37
        $mock = $this->getMockBuilder('Communibase\Connector')
38
                ->setMethods(['getResult'])
39
                ->disableOriginalConstructor()
40
                ->getMock();
41
42
        $mock->expects($this->any())
43
            ->method('getResult')
44
            ->will($this->returnValue(new FulfilledPromise([])));
45
46
        return $mock;
47
    }
48
}
49