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

SearchRequestTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 26
dl 0
loc 60
c 0
b 0
f 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 3 1
A setUp() 0 5 1
A testSetProjectionExpression() 0 4 1
A testSetConsistentRead() 0 10 1
A testSetIndexName() 0 4 1
A testSetSelect() 0 4 1
A testSetScanIndexForward() 0 10 1
1
<?php
2
3
namespace GuillermoandraeTest\DynamoDb;
4
5
use Aws\DynamoDb\Marshaler;
6
use Guillermoandrae\DynamoDb\AbstractSearchRequest;
7
use PHPUnit\Framework\TestCase;
8
9
final class SearchRequestTest extends TestCase
10
{
11
    /**
12
     * @var AbstractSearchRequest The request.
13
     */
14
    private $request;
15
16
    public function testSetScanIndexForward()
17
    {
18
        $this->request->setScanIndexForward(true);
19
        $expectedQuery = [
20
            'TableName' => 'test',
21
            'ScanIndexForward' => true,
22
            'ConsistentRead' => false,
23
            'ReturnConsumedCapacity' => 'NONE'
24
        ];
25
        $this->assertEquals($expectedQuery, $this->request->toArray());
26
    }
27
28
    public function testSetConsistentRead()
29
    {
30
        $this->request->setConsistentRead(true);
31
        $expectedQuery = [
32
            'TableName' => 'test',
33
            'ScanIndexForward' => false,
34
            'ConsistentRead' => true,
35
            'ReturnConsumedCapacity' => 'NONE'
36
        ];
37
        $this->assertEquals($expectedQuery, $this->request->toArray());
38
    }
39
40
    public function testSetIndexName()
41
    {
42
        $this->request->setIndexName('test');
43
        $this->assertEquals('test', $this->request->toArray()['IndexName']);
44
    }
45
46
    public function testSetSelect()
47
    {
48
        $this->request->setSelect(AbstractSearchRequest::SELECT_ALL_ATTRIBUTES);
49
        $this->assertEquals('ALL_ATTRIBUTES', $this->request->toArray()['Select']);
50
    }
51
52
    public function testSetProjectionExpression()
53
    {
54
        $this->request->setProjectionExpression('test');
55
        $this->assertEquals('test', $this->request->toArray()['ProjectionExpression']);
56
    }
57
58
    protected function setUp(): void
59
    {
60
        $this->request = $this->getMockForAbstractClass(
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...b\Marshaler(), 'test')) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Guillermoandrae\DynamoDb\AbstractSearchRequest 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...
61
            AbstractSearchRequest::class,
62
            [new Marshaler(), 'test']
63
        );
64
    }
65
66
    protected function tearDown(): void
67
    {
68
        $this->request = null;
69
    }
70
}
71