Completed
Push — async-first ( 0001b9...fc551c )
by
unknown
03:44
created

SyncTest::async()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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