Completed
Pull Request — master (#23)
by
unknown
02:07
created

SyncTest::sync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
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 sync()
18
    {
19
        $result = $this->getMockConnector()->getByIdSync('Person', $this->getMockConnector()->generateId());
20
        $this->assertSame([], $result);
21
    }
22
23
    /**
24
     * @test
25
     */
26
    public function async()
27
    {
28
        $this->getMockConnector()->getById('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
    {
38
        $mock = $this->getMockBuilder('Communibase\Connector')
39
                     ->setMethods(['getResult'])
40
                     ->disableOriginalConstructor()
41
                     ->getMock();
42
43
        $mock->expects($this->any())
44
             ->method('getResult')
45
             ->will($this->returnValue(new FulfilledPromise([])));
46
47
        return $mock;
48
    }
49
}
50