Completed
Push — master ( e15fb0...634cc5 )
by Guillermo A.
02:14
created

testSetPartitionKeyConditionExpression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GuillermoandraeTest\Db\DynamoDb;
4
5
use Aws\DynamoDb\Marshaler;
6
use Guillermoandrae\Db\DynamoDb\QueryRequest;
7
use Guillermoandrae\Db\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', RequestOperators::GTE, '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', RequestOperators::GTE, '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