Completed
Push — master ( 20a668...02e94f )
by Guillermo A.
02:17
created

testSetPartitionKeyConditionExpression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GuillermoandraeTest\DynamoDb;
4
5
use Aws\DynamoDb\Marshaler;
6
use Guillermoandrae\DynamoDb\QueryRequest;
7
use Guillermoandrae\DynamoDb\RequestOperators;
8
use PHPUnit\Framework\TestCase;
9
10
final class QueryRequestTest extends TestCase
11
{
12
    /**
13
     * @var QueryRequest The request.
14
     */
15
    private $request;
16
17
    public function testSetPartitionKeyConditionExpression()
18
    {
19
        $this->request->setPartitionKeyConditionExpression('test', 'something');
20
        $requestArray = $this->request->toArray();
21
        $this->assertEquals('test = :test', $requestArray['KeyConditionExpression']);
22
        $this->assertEquals(['S' => 'something'], $requestArray['ExpressionAttributeValues'][':test']);
23
    }
24
25
    public function testSetSortKeyConditionExpression()
26
    {
27
        $this->request->setPartitionKeyConditionExpression('test', 'something');
28
        $this->request->setSortKeyConditionExpression('anotherTest', RequestOperators::BEGINS_WITH, 'somethingElse');
29
        $requestArray = $this->request->toArray();
30
        $this->assertEquals(
31
            'test = :test AND begins_with(anotherTest, :anotherTest)',
32
            $requestArray['KeyConditionExpression']
33
        );
34
        $this->assertEquals(['S' => 'something'], $requestArray['ExpressionAttributeValues'][':test']);
35
        $this->assertEquals(['S' => 'somethingElse'], $requestArray['ExpressionAttributeValues'][':anotherTest']);
36
    }
37
38
    protected function setUp(): void
39
    {
40
        $this->request = new QueryRequest(new Marshaler(), 'test');
41
    }
42
43
    protected function tearDown(): void
44
    {
45
        $this->request = null;
46
    }
47
}
48