From f862ade53b5ffe8d1da0f43e1fb70090449888fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 5 Jul 2023 10:55:42 -0300 Subject: [PATCH] Improve unit tests for the Navigation\NodeFactory class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- test/classes/Navigation/NodeFactoryTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/classes/Navigation/NodeFactoryTest.php b/test/classes/Navigation/NodeFactoryTest.php index 12cdd2834c..3140020496 100644 --- a/test/classes/Navigation/NodeFactoryTest.php +++ b/test/classes/Navigation/NodeFactoryTest.php @@ -6,6 +6,7 @@ namespace PhpMyAdmin\Tests\Navigation; use PhpMyAdmin\Navigation\NodeFactory; use PhpMyAdmin\Navigation\Nodes\Node; +use PhpMyAdmin\Navigation\Nodes\NodeDatabase; use PhpMyAdmin\Tests\AbstractTestCase; use PHPUnit\Framework\Attributes\CoversClass; @@ -46,4 +47,24 @@ class NodeFactoryTest extends AbstractTestCase $this->assertEquals(Node::CONTAINER, $node->type); $this->assertTrue($node->isGroup); } + + public function testDatabaseNode(): void + { + $node = NodeFactory::getInstance(NodeDatabase::class, 'database_name'); + $this->assertInstanceOf(NodeDatabase::class, $node); + $this->assertEquals('database_name', $node->name); + $this->assertEquals(Node::OBJECT, $node->type); + $this->assertFalse($node->isGroup); + } + + public function testGetInstanceForNewNode(): void + { + $node = NodeFactory::getInstanceForNewNode('New', 'new_database italics'); + $this->assertEquals('New', $node->name); + $this->assertEquals(Node::OBJECT, $node->type); + $this->assertFalse($node->isGroup); + $this->assertEquals('New', $node->title); + $this->assertTrue($node->isNew); + $this->assertEquals('new_database italics', $node->classes); + } }