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