Improve unit tests for the Navigation\NodeFactory class

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2023-07-05 10:55:42 -03:00
parent 51aab42a7a
commit f862ade53b
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8

View File

@ -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);
}
}