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

SearchRequestTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
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\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\Db\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