BatchQueryResultTest::testBatchWithIndexBy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
rs 10
c 0
b 0
f 0
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
11
final class BatchQueryResultTest extends \Yiisoft\ActiveRecord\Tests\BatchQueryResultTest
12
{
13
    public function setUp(): void
14
    {
15
        parent::setUp();
16
17
        $oracleHelper = new OracleHelper();
18
        $this->db = $oracleHelper->createConnection();
19
    }
20
21
    protected function tearDown(): void
22
    {
23
        parent::tearDown();
24
25
        $this->db->close();
26
27
        unset($this->db);
28
    }
29
30
    public function testBatchWithIndexBy(): void
31
    {
32
        $this->checkFixture($this->db, 'customer');
33
34
        $customerQuery = new ActiveQuery(Customer::class, $this->db);
35
36
        $query = $customerQuery->orderBy('id')->limit(3)->indexBy('id');
37
38
        $customers = $this->getAllRowsFromBatch($query->batch(2));
39
40
        $this->assertCount(3, $customers);
41
        $this->assertEquals('user1', $customers[0]->getName());
42
        $this->assertEquals('user2', $customers[1]->getName());
43
        $this->assertEquals('user3', $customers[2]->getName());
44
    }
45
}
46