Completed
Branch trunk (78000f)
by SuperNova.WS
25:55 queued 09:00
created

InvokerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2
1
<?php
2
3
/**
4
 * Created by Gorlum 10.08.2016 21:29
5
 */
6
7
use Common\Invoker;
8
9
/**
10
 * Class InvokerTest
11
 * @coversDefaultClass \Common\Invoker
12
 */
13
class InvokerTest extends PHPUnit_Framework_TestCase {
14
15
  public function publicFunction() {
16
    return 'public';
17
  }
18
19
  protected function protectedFunction() {
20
    return 'protected';
21
  }
22
23
  /**
24
   * @covers ::build
25
   * @covers ::__construct
26
   * @covers ::__invoke
27
   */
28
  public function testBuild() {
29
    $t = Invoker::build(12345);
30
    $this->assertNull($t());
31
32
    $t = Invoker::build(array($this, 'protectedFunction'));
33
    $this->assertNull($t());
34
35
36
    $t = Invoker::build(function () { return 'lambda';});
37
    $this->assertEquals('lambda', $t());
38
39
    $t = Invoker::build(array($this, 'publicFunction'));
40
    $this->assertEquals('public', $t());
41
42
    $t = Invoker::build('mt_rand');
43
    $this->assertTrue(is_integer($t()));
44
45
//    $t = Invoker::build('array_unshift');
46
//    $array = array('q');
47
//    $this->assertEquals(2, $t($array, 'w'));
48
//    // TODO - uncomment for PHP > 5.3
49
//    $this->assertEquals(array('w', 'q'), $array);
50
  }
51
52
}
53