|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GuillermoandraeTest\Db\DynamoDb; |
|
4
|
|
|
|
|
5
|
|
|
use Aws\DynamoDb\Marshaler; |
|
6
|
|
|
use Guillermoandrae\Db\DynamoDb\AbstractSearchRequest; |
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
|
|
9
|
|
|
final class SearchRequestTest extends TestCase |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var AbstractSearchRequest The request. |
|
13
|
|
|
*/ |
|
14
|
|
|
private $request; |
|
15
|
|
|
|
|
16
|
|
|
public function testSetScanIndexForward() |
|
17
|
|
|
{ |
|
18
|
|
|
$this->request->setScanIndexForward(true); |
|
19
|
|
|
$expectedQuery = [ |
|
20
|
|
|
'TableName' => 'test', |
|
21
|
|
|
'ScanIndexForward' => true, |
|
22
|
|
|
'ConsistentRead' => false, |
|
23
|
|
|
'ReturnConsumedCapacity' => 'NONE' |
|
24
|
|
|
]; |
|
25
|
|
|
$this->assertEquals($expectedQuery, $this->request->toArray()); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testSetConsistentRead() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->request->setConsistentRead(true); |
|
31
|
|
|
$expectedQuery = [ |
|
32
|
|
|
'TableName' => 'test', |
|
33
|
|
|
'ScanIndexForward' => false, |
|
34
|
|
|
'ConsistentRead' => true, |
|
35
|
|
|
'ReturnConsumedCapacity' => 'NONE' |
|
36
|
|
|
]; |
|
37
|
|
|
$this->assertEquals($expectedQuery, $this->request->toArray()); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function testSetIndexName() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->request->setIndexName('test'); |
|
43
|
|
|
$this->assertEquals('test', $this->request->toArray()['IndexName']); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testSetSelect() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->request->setSelect(AbstractSearchRequest::SELECT_ALL_ATTRIBUTES); |
|
49
|
|
|
$this->assertEquals('ALL_ATTRIBUTES', $this->request->toArray()['Select']); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testSetProjectionExpression() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->request->setProjectionExpression('test'); |
|
55
|
|
|
$this->assertEquals('test', $this->request->toArray()['ProjectionExpression']); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function setUp(): void |
|
59
|
|
|
{ |
|
60
|
|
|
$this->request = $this->getMockForAbstractClass( |
|
|
|
|
|
|
61
|
|
|
AbstractSearchRequest::class, |
|
62
|
|
|
[new Marshaler(), 'test'] |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
protected function tearDown(): void |
|
67
|
|
|
{ |
|
68
|
|
|
$this->request = null; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
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..