1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (C) 2017 Gerrit Addiks. |
4
|
|
|
* This package (including this file) was released under the terms of the GPL-3.0. |
5
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
6
|
|
|
* If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy. |
7
|
|
|
* @license GPL-3.0 |
8
|
|
|
* @author Gerrit Addiks <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Addiks; |
12
|
|
|
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
use Addiks\SymfonyGenerics\Arguments\ArgumentFactory\ArgumentCallFactory; |
15
|
|
|
use Addiks\SymfonyGenerics\Arguments\ArgumentFactory\ArgumentFactory; |
16
|
|
|
|
17
|
|
|
final class ArgumentCallFactoryTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var ArgumentCallFactory |
22
|
|
|
*/ |
23
|
|
|
private $factory; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var ArgumentFactory |
27
|
|
|
*/ |
28
|
|
|
private $argumentFactory; |
29
|
|
|
|
30
|
|
|
public function setUp() |
31
|
|
|
{ |
32
|
|
|
$this->argumentFactory = $this->createMock(ArgumentFactory::class); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$this->factory = new ArgumentCallFactory($this->argumentFactory); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @test |
39
|
|
|
* @dataProvider dataProviderForShouldKnowIfUnderstandString |
40
|
|
|
*/ |
41
|
|
|
public function shouldKnowIfUnderstandString(bool $expectedResult, string $source) |
42
|
|
|
{ |
43
|
|
|
/** @var bool $actualResult */ |
44
|
|
|
$actualResult = $this->factory->understandsString($source); |
45
|
|
|
|
46
|
|
|
$this->assertEquals($expectedResult, $actualResult); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function dataProviderForShouldKnowIfUnderstandString() |
50
|
|
|
{ |
51
|
|
|
return array( |
52
|
|
|
[true, 'a::b'], |
53
|
|
|
[true, 'foo::bar'], |
54
|
|
|
[true, 'foo::bar(baz)'], |
55
|
|
|
[false, '::b'], |
56
|
|
|
[false, 'a::'], |
57
|
|
|
[false, '::'], |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @test |
63
|
|
|
* @dataProvider dataProviderForShouldKnowIfUnderstandArray |
64
|
|
|
*/ |
65
|
|
|
public function shouldKnowIfUnderstandArray(bool $expectedResult, array $source) |
66
|
|
|
{ |
67
|
|
|
/** @var bool $actualResult */ |
68
|
|
|
$actualResult = $this->factory->understandsArray($source); |
69
|
|
|
|
70
|
|
|
$this->assertEquals($expectedResult, $actualResult); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function dataProviderForShouldKnowIfUnderstandArray() |
74
|
|
|
{ |
75
|
|
|
return array( |
76
|
|
|
[true, ['callee' => 'foo', 'method' => 'bar']], |
77
|
|
|
[true, ['callee' => 'foo', 'method' => 'bar', 'arguments' => []]], |
78
|
|
|
[false, ['method' => 'bar']], |
79
|
|
|
[false, ['callee' => 'foo']], |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..