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

TestDataReaderProviderTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 28
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testTotalCountWithParams() 0 8 1
A testGetModels() 0 7 1
A testTotalCount() 0 7 1
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