Passed
Pull Request — master (#376)
by Wilmer
05:03 queued 02:33
created

BetweenColumnsConditionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
b 0
f 0
dl 0
loc 16
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testException() 0 5 1
A testConstructor() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\QueryBuilder\Conditions;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Db\Exception\InvalidArgumentException;
9
use Yiisoft\Db\QueryBuilder\Conditions\BetweenColumnsCondition;
10
11
/**
12
 * @group db
13
 */
14
final class BetweenColumnsConditionTest extends TestCase
15
{
16
    public function testConstructor(): void
17
    {
18
        $condition = new BetweenColumnsCondition(42, 'BETWEEN', 'min_value', 'max_value');
19
        $this->assertSame(42, $condition->getValue());
20
        $this->assertSame('BETWEEN', $condition->getOperator());
21
        $this->assertSame('min_value', $condition->getIntervalStartColumn());
22
        $this->assertSame('max_value', $condition->getIntervalEndColumn());
23
    }
24
25
    public function testException(): void
26
    {
27
        $this->expectException(InvalidArgumentException::class);
28
        $this->expectExceptionMessage("Operator 'between' requires three operands.");
29
        BetweenColumnsCondition::fromArrayDefinition('between', []);
30
    }
31
}
32