Completed
Push — master ( a7a349...3fc402 )
by Guillermo A.
03:23
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
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GuillermoandraeTest\DynamoDb\Operation;
4
5
use Guillermoandrae\DynamoDb\Constant\Operators;
6
use Guillermoandrae\DynamoDb\Factory\DynamoDbClientFactory;
7
use Guillermoandrae\DynamoDb\Factory\MarshalerFactory;
8
use Guillermoandrae\DynamoDb\Operation\QueryOperation;
9
use PHPUnit\Framework\TestCase;
10
11
final class QueryOperationTest extends TestCase
12
{
13
    /**
14
     * @var QueryOperation The request.
15
     */
16
    private $request;
17
18
    public function testSetPartitionKeyConditionExpression()
19
    {
20
        $this->request->setPartitionKeyConditionExpression('test', 'something');
21
        $requestArray = $this->request->toArray();
22
        $this->assertEquals('test = :test', $requestArray['KeyConditionExpression']);
23
        $this->assertEquals(['S' => 'something'], $requestArray['ExpressionAttributeValues'][':test']);
24
    }
25
26
    public function testSetSortKeyConditionExpression()
27
    {
28
        $this->request->setPartitionKeyConditionExpression('test', 'something');
29
        $this->request->setSortKeyConditionExpression('anotherTest', Operators::BEGINS_WITH, 'somethingElse');
30
        $requestArray = $this->request->toArray();
31
        $this->assertEquals(
32
            'test = :test AND begins_with(anotherTest, :anotherTest)',
33
            $requestArray['KeyConditionExpression']
34
        );
35
        $this->assertEquals(['S' => 'something'], $requestArray['ExpressionAttributeValues'][':test']);
36
        $this->assertEquals(['S' => 'somethingElse'], $requestArray['ExpressionAttributeValues'][':anotherTest']);
37
    }
38
39
    protected function setUp(): void
40
    {
41
        $this->request = new QueryOperation(DynamoDbClientFactory::factory(), MarshalerFactory::factory(), 'test');
42
    }
43
44
    protected function tearDown(): void
45
    {
46
        $this->request = null;
47
    }
48
}
49