Completed
Push — master ( a7a349...3fc402 )
by Guillermo A.
03:23
created

SearchOperationTest::testSetConsistentRead()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 0
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(
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...ry::factory(), 'test')) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Guillermoandrae\DynamoDb...AbstractSearchOperation of property $request.

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..

Loading history...
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