Passed
Push — master ( 763c33...debe09 )
by Wilmer
29:07 queued 26:37
created

NotConditionTest::testConstructor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\QueryBuilder\Condition;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Db\Exception\InvalidArgumentException;
9
use Yiisoft\Db\QueryBuilder\Conditions\NotCondition;
10
11
/**
12
 * @group db
13
 */
14
final class NotConditionTest extends TestCase
15
{
16
    public function testConstructor(): void
17
    {
18
        $notCondition = new NotCondition('id = 1');
19
20
        $this->assertSame('id = 1', $notCondition->getCondition());
21
    }
22
23
    public function testFromArrayDefinition(): void
24
    {
25
        $notCondition = NotCondition::fromArrayDefinition('NOT', ['id = 1']);
26
27
        $this->assertSame('id = 1', $notCondition->getCondition());
28
    }
29
30
    public function testFromArrayDefinitionException(): void
31
    {
32
        $this->expectException(InvalidArgumentException::class);
33
        $this->expectExceptionMessage("Operator 'NOT' requires exactly one operand.");
34
        NotCondition::fromArrayDefinition('NOT', []);
35
    }
36
37
    public function testFromArrayDefinitionExceptionCondition(): void
38
    {
39
        $this->expectException(InvalidArgumentException::class);
40
        $this->expectExceptionMessage(
41
            "Operator 'NOT' requires condition to be array, string, null or ExpressionInterface."
42
        );
43
        NotCondition::fromArrayDefinition('NOT', [false]);
44
    }
45
}
46