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

SyncTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 6
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSync() 0 5 1
A testAsync() 0 6 1
A getMockConnector() 0 12 1
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