Completed
Push — master ( 3de66b...11beb8 )
by Rafał
08:38
created

ContainerNodeTest::getTests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 9.376
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Templates System.
5
 *
6
 * Copyright 2015 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\TemplatesSystem\Tests\Twig\Node;
16
17
use SWP\Component\TemplatesSystem\Twig\Node\ContainerNode;
18
use Twig\Node\Expression\ArrayExpression;
19
use Twig\Node\Expression\ConstantExpression;
20
use Twig\Node\Node;
21
use Twig\Node\TextNode;
22
use Twig\Test\NodeTestCase;
23
24
class ContainerNodeTest extends NodeTestCase
25
{
26 View Code Duplication
    public function testConstructor()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $name = new Node([new ConstantExpression('container_name', 1)]);
29
        $parameters = new ArrayExpression([], 1);
30
        $body = new TextNode('', 1);
31
        $node = new ContainerNode($name, $parameters, $body, 1, 'gimme');
0 ignored issues
show
Deprecated Code introduced by
The class SWP\Component\TemplatesS...Twig\Node\ContainerNode has been deprecated with message: since 2.0, will be removed in 3.0
Container twig node.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
32
        $this->assertEquals($name, $node->getNode('name'));
33
        $this->assertEquals($parameters, $node->getNode('parameters'));
34
        $this->assertEquals($body, $node->getNode('body'));
35
    }
36
37
    public function getTests()
38
    {
39
        $name1 = new Node([new ConstantExpression('container_name', 1)]);
40
        $parameters1 = new ArrayExpression([], 1);
41
        $body1 = new TextNode('Test body', 1);
42
        $node1 = new ContainerNode($name1, $parameters1, $body1, 1, 'gimme');
0 ignored issues
show
Deprecated Code introduced by
The class SWP\Component\TemplatesS...Twig\Node\ContainerNode has been deprecated with message: since 2.0, will be removed in 3.0
Container twig node.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
43
44
        $name2 = new Node([new ConstantExpression('container_name', 2)]);
45
        $body2 = new TextNode('Test body', 2);
46
        $node2 = new ContainerNode($name2, null, $body2, 2, 'gimme');
0 ignored issues
show
Deprecated Code introduced by
The class SWP\Component\TemplatesS...Twig\Node\ContainerNode has been deprecated with message: since 2.0, will be removed in 3.0
Container twig node.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
47
48
        $name3 = new Node([new ConstantExpression('container_name', 3)]);
49
        $parameters3 = new ArrayExpression([new ConstantExpression('foo', 1), new ConstantExpression(true, 1)], 1);
50
        $body3 = new TextNode('Test body', 3);
51
        $node3 = new ContainerNode($name3, $parameters3, $body3, 3, 'gimme');
0 ignored issues
show
Deprecated Code introduced by
The class SWP\Component\TemplatesS...Twig\Node\ContainerNode has been deprecated with message: since 2.0, will be removed in 3.0
Container twig node.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
52
53
        return [
54
            [$node1, <<<'EOF'
55
// line 1
56
echo "<!-- @deprecated: Container nodes are deprecated from 2.0, will be removed in 3.0 -->";
57
EOF
58
            ],
59
            [$node2, <<<'EOF'
60
// line 2
61
echo "<!-- @deprecated: Container nodes are deprecated from 2.0, will be removed in 3.0 -->";
62
EOF
63
            ],
64
            [$node3, <<<'EOF'
65
// line 3
66
echo "<!-- @deprecated: Container nodes are deprecated from 2.0, will be removed in 3.0 -->";
67
EOF
68
            ],
69
        ];
70
    }
71
72 View Code Duplication
    protected function tearDown()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    {
74
        $reflection = new \ReflectionObject($this);
75
        foreach ($reflection->getProperties() as $prop) {
76
            if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
0 ignored issues
show
introduced by
Consider using $prop->class. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
77
                $prop->setAccessible(true);
78
                $prop->setValue($this, null);
79
            }
80
        }
81
    }
82
}
83