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

TestDataReaderProviderTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 28
rs 10
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
    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