Completed
Push — master ( c5c436...b453a3 )
by Ruud
15:58
created

NodeBundle/Tests/unit/Entity/StructureNodeTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\NodeBundle\Tests\Entity;
4
5
use Kunstmaan\NodeBundle\Entity\AbstractPage;
6
use Kunstmaan\NodeBundle\Entity\HasNodeInterface;
7
use Kunstmaan\NodeBundle\Entity\StructureNode;
8
use Kunstmaan\NodeBundle\Form\PageAdminType;
9
use Kunstmaan\NodeBundle\Helper\RenderContext;
10
use PHPUnit\Framework\TestCase;
11
use Symfony\Component\DependencyInjection\Container;
12
use Symfony\Component\HttpFoundation\Request;
13
14
class TestStructureNode extends StructureNode
15
{
16
    public function getPossibleChildTypes()
17
    {
18
        return [];
19
    }
20
}
21
22
class TestNode extends AbstractPage
23
{
24
    public function getPossibleChildTypes()
25
    {
26
        return [];
27
    }
28
}
29
30
/**
31
 * Class StructureNodeTest
32
 */
33
class StructureNodeTest extends TestCase
34
{
35
    public function testIsStructureNode()
36
    {
37
        $structureNode = new TestStructureNode();
38
        $this->assertTrue($structureNode->isStructureNode());
39
40
        $node = new TestNode();
41
        $this->assertFalse($node->isStructureNode());
42
    }
43
44
    public function testIsOnline()
45
    {
46
        $structureNode = new TestStructureNode();
47
        $this->assertFalse($structureNode->isOnline());
48
    }
49
50
    public function testGetSetPageTitle()
51
    {
52
        $node = new TestStructureNode();
53
        $node->setTitle('The Title');
54
        $this->assertEquals('The Title', $node->getPageTitle());
55
        $this->assertEquals('The Title', $node->getTitle());
56
        $this->assertEquals('The Title', $node->__toString());
57
    }
58
59
    public function testGetSetParent()
60
    {
61
        $entity = $this->createMock(HasNodeInterface::class);
62
        $node = new TestStructureNode();
63
        $node->setParent($entity);
64
        $this->assertInstanceOf(get_class($entity), $node->getParent());
65
    }
66
67
    public function testGetDefaultAdminType()
68
    {
69
        $node = new TestStructureNode();
70
        $this->assertEquals(PageAdminType::class, $node->getDefaultAdminType());
71
    }
72
73
    public function testService()
74
    {
75
        // this method does nothing - is it required?
76
        $node = new TestStructureNode();
77
        $node->service(new Container(), new Request(), new RenderContext());
0 ignored issues
show
Deprecated Code introduced by
The method Kunstmaan\NodeBundle\Ent...AbstractPage::service() has been deprecated with message: Using the service method is deprecated in KunstmaanNodeBundle 5.1 and will be removed in KunstmaanNodeBundle 6.0. Implement SlugActionInterface and use the getControllerAction method to provide custom logic instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

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

Loading history...
78
    }
79
}
80