Passed
Pull Request — master (#368)
by Sergei
02:51
created

BatchQueryResultTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
c 0
b 0
f 0
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testBatchWithIndexBy() 0 14 1
A createConnection() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Driver\Oracle;
6
7
use Yiisoft\ActiveRecord\ActiveQuery;
8
use Yiisoft\ActiveRecord\Tests\Driver\Oracle\Stubs\Customer;
9
use Yiisoft\ActiveRecord\Tests\Support\OracleHelper;
10
use Yiisoft\Db\Connection\ConnectionInterface;
11
12
final class BatchQueryResultTest extends \Yiisoft\ActiveRecord\Tests\BatchQueryResultTest
13
{
14
    protected function createConnection(): ConnectionInterface
15
    {
16
        return (new OracleHelper())->createConnection();
17
    }
18
19
    public function testBatchWithIndexBy(): void
20
    {
21
        $this->checkFixture($this->db(), 'customer');
22
23
        $customerQuery = new ActiveQuery(Customer::class);
24
25
        $query = $customerQuery->orderBy('id')->limit(3)->indexBy('id');
26
27
        $customers = $this->getAllRowsFromBatch($query->batch(2));
28
29
        $this->assertCount(3, $customers);
30
        $this->assertEquals('user1', $customers[0]->getName());
31
        $this->assertEquals('user2', $customers[1]->getName());
32
        $this->assertEquals('user3', $customers[2]->getName());
33
    }
34
}
35