Passed
Pull Request — master (#163)
by Wilmer
17:48 queued 02:54
created

TestDataReaderProviderTrait::testTotalCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\TestUtility;
6
7
use Yiisoft\Db\Data\DataReaderProvider;
8
9
trait TestDataReaderProviderTrait
10
{
11
    public function testGetModels(): void
12
    {
13
        $dataProvider = (new DataReaderProvider())
14
            ->sql('select * from customer')
15
            ->db($this->getConnection());
0 ignored issues
show
Bug introduced by
It seems like getConnection() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
            ->db($this->/** @scrutinizer ignore-call */ getConnection());
Loading history...
16
17
        $this->assertCount(3, $dataProvider->getModels());
0 ignored issues
show
Bug introduced by
It seems like assertCount() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $this->/** @scrutinizer ignore-call */ 
18
               assertCount(3, $dataProvider->getModels());
Loading history...
18
    }
19
20
    public function testTotalCount(): void
21
    {
22
        $dataProvider = (new DataReaderProvider())
23
            ->sql('select * from customer')
24
            ->db($this->getConnection());
25
26
        $this->assertEquals(3, $dataProvider->getTotalCount());
0 ignored issues
show
Bug introduced by
It seems like assertEquals() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $this->/** @scrutinizer ignore-call */ 
27
               assertEquals(3, $dataProvider->getTotalCount());
Loading history...
27
    }
28
29
    public function testTotalCountWithParams(): void
30
    {
31
        $dataProvider = (new DataReaderProvider())
32
            ->sql('select * from customer where id > :minimum')
33
            ->params([':minimum' => -1])
34
            ->db($this->getConnection());
35
36
        $this->assertEquals(3, $dataProvider->getTotalCount());
37
    }
38
}
39