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

BatchQueryResultTest::createConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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