Skip to content

Commit f862ade

Browse files
committed
Improve unit tests for the Navigation\NodeFactory class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 51aab42 commit f862ade

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/classes/Navigation/NodeFactoryTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpMyAdmin\Navigation\NodeFactory;
88
use PhpMyAdmin\Navigation\Nodes\Node;
9+
use PhpMyAdmin\Navigation\Nodes\NodeDatabase;
910
use PhpMyAdmin\Tests\AbstractTestCase;
1011
use PHPUnit\Framework\Attributes\CoversClass;
1112

@@ -46,4 +47,24 @@ public function testGroupContainer(): void
4647
$this->assertEquals(Node::CONTAINER, $node->type);
4748
$this->assertTrue($node->isGroup);
4849
}
50+
51+
public function testDatabaseNode(): void
52+
{
53+
$node = NodeFactory::getInstance(NodeDatabase::class, 'database_name');
54+
$this->assertInstanceOf(NodeDatabase::class, $node);
55+
$this->assertEquals('database_name', $node->name);
56+
$this->assertEquals(Node::OBJECT, $node->type);
57+
$this->assertFalse($node->isGroup);
58+
}
59+
60+
public function testGetInstanceForNewNode(): void
61+
{
62+
$node = NodeFactory::getInstanceForNewNode('New', 'new_database italics');
63+
$this->assertEquals('New', $node->name);
64+
$this->assertEquals(Node::OBJECT, $node->type);
65+
$this->assertFalse($node->isGroup);
66+
$this->assertEquals('New', $node->title);
67+
$this->assertTrue($node->isNew);
68+
$this->assertEquals('new_database italics', $node->classes);
69+
}
4970
}

0 commit comments

Comments
 (0)