getTests()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Empty Coalesce plugin for Craft CMS 3.x
4
 *
5
 * Empty Coalesce adds the ??? operator to Twig that will return the first thing
6
 * that is defined, not null, and not empty.
7
 *
8
 * @link      https://nystudio107.com/
9
 * @copyright Copyright (c) 2018 nystudio107
10
 */
11
12
use nystudio107\emptycoalesce\Node\Expression\EmptyCoalesceExpression;
13
14
use Twig\Node\Expression\ConstantExpression;
15
use Twig\Node\Expression\NameExpression;
16
use Twig\Test\NodeTestCase;
17
18
/**
19
 * @author    nystudio107
20
 * @package   EmptyCoalesce
21
 * @since     1.0.0
22
 *
23
 */
24
class Twig_Tests_Node_Expression_EmptyCoalesceTest extends NodeTestCase
25
{
26
    public function getTests()
27
    {
28
        $left = new NameExpression('foo', 1);
29
        $right = new ConstantExpression(2, 1);
30
        $node = new EmptyCoalesceExpression($left, $right, 1);
31
32
        return array(array($node, "((".EmptyCoalesceExpression::class."::empty(// line 1\n(\$context[\"foo\"] ?? null)) ? null : (\$context[\"foo\"] ?? null)) ?? (".EmptyCoalesceExpression::class."::empty(2) ? null : 2))"));
33
    }
34
}
35