Passed
Push — master ( be06f7...c027e3 )
by Wilmer
08:58 queued 06:59
created

TestDataReaderProviderTrait::testGetModels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 1
    public function testGetModels(): void
12
    {
13 1
        $dataProvider = (new DataReaderProvider())
14 1
            ->sql('SELECT * FROM {{customer}}')
15 1
            ->db($this->getConnection(true));
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(true));
Loading history...
16
17 1
        $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 1
    }
19
20 1
    public function testTotalCount(): void
21
    {
22 1
        $dataProvider = (new DataReaderProvider())
23 1
            ->sql('SELECT * FROM {{customer}}')
24 1
            ->db($this->getConnection());
25
26 1
        $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 1
    }
28
29 1
    public function testTotalCountWithParams(): void
30
    {
31 1
        $dataProvider = (new DataReaderProvider())
32 1
            ->sql('SELECT * FROM {{customer}} WHERE [[id]] > :minimum')
33 1
            ->params([':minimum' => -1])
34 1
            ->db($this->getConnection());
35
36 1
        $this->assertEquals(3, $dataProvider->getTotalCount());
37 1
    }
38
}
39