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\SymfonyGenerics\Tests\Unit\Arguments\ArgumentFactory; |
12
|
|
|
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
use Addiks\SymfonyGenerics\Arguments\ArgumentFactory\RequestPayloadArgumentFactory; |
15
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
16
|
|
|
use Addiks\SymfonyGenerics\Arguments\RequestPayloadArgument; |
17
|
|
|
|
18
|
|
|
final class RequestPayloadArgumentFactoryTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var RequestPayloadArgumentFactory |
23
|
|
|
*/ |
24
|
|
|
private $factory; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var RequestStack |
28
|
|
|
*/ |
29
|
|
|
private $requestStack; |
30
|
|
|
|
31
|
|
|
public function setUp() |
32
|
|
|
{ |
33
|
|
|
$this->requestStack = $this->createMock(RequestStack::class); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$this->factory = new RequestPayloadArgumentFactory($this->requestStack); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @test |
40
|
|
|
*/ |
41
|
|
|
public function shouldKnowIfUnderstandString() |
42
|
|
|
{ |
43
|
|
|
$this->assertEquals(true, $this->factory->understandsString("$")); |
44
|
|
|
$this->assertEquals(false, $this->factory->understandsString("not $")); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @test |
49
|
|
|
*/ |
50
|
|
|
public function shouldKnowIfUnderstandArray() |
51
|
|
|
{ |
52
|
|
|
$this->assertEquals(true, $this->factory->understandsArray(['type' => 'request-payload'])); |
53
|
|
|
$this->assertEquals(false, $this->factory->understandsArray(['type' => 'anything else'])); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @test |
58
|
|
|
*/ |
59
|
|
|
public function shouldCreateArguments() |
60
|
|
|
{ |
61
|
|
|
$this->assertEquals( |
62
|
|
|
new RequestPayloadArgument($this->requestStack), |
63
|
|
|
$this->factory->createArgumentFromString("") |
64
|
|
|
); |
65
|
|
|
$this->assertEquals( |
66
|
|
|
new RequestPayloadArgument($this->requestStack), |
67
|
|
|
$this->factory->createArgumentFromArray([]) |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
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..