From ac2b931c7b0f07726bb5bf99351b2f3fd3cf8a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 7 Jul 2023 13:37:24 -0300 Subject: [PATCH] Improve unit tests for NodeColumnContainer nav class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- .../Nodes/NodeColumnContainerTest.php | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/test/classes/Navigation/Nodes/NodeColumnContainerTest.php b/test/classes/Navigation/Nodes/NodeColumnContainerTest.php index aba54fa0c8..0695470ab1 100644 --- a/test/classes/Navigation/Nodes/NodeColumnContainerTest.php +++ b/test/classes/Navigation/Nodes/NodeColumnContainerTest.php @@ -4,23 +4,49 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Navigation\Nodes; +use PhpMyAdmin\Navigation\Nodes\Node; use PhpMyAdmin\Navigation\Nodes\NodeColumnContainer; use PhpMyAdmin\Tests\AbstractTestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(NodeColumnContainer::class)] -class NodeColumnContainerTest extends AbstractTestCase +final class NodeColumnContainerTest extends AbstractTestCase { - public function testConstructor(): void + public function testColumnContainer(): void { - $parent = new NodeColumnContainer(); - $this->assertEquals( + $nodeColumnContainer = new NodeColumnContainer(); + $this->assertSame('Columns', $nodeColumnContainer->name); + $this->assertSame(Node::CONTAINER, $nodeColumnContainer->type); + $this->assertFalse($nodeColumnContainer->isGroup); + $this->assertSame(['image' => 'pause', 'title' => 'Columns'], $nodeColumnContainer->icon); + $this->assertSame( [ 'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]], 'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]], ], - $parent->links, + $nodeColumnContainer->links, + ); + $this->assertSame('columns', $nodeColumnContainer->realName); + $this->assertCount(1, $nodeColumnContainer->children); + $this->assertArrayHasKey(0, $nodeColumnContainer->children); + $newNode = $nodeColumnContainer->children[0]; + $this->assertSame('New', $newNode->name); + $this->assertSame('New', $newNode->title); + $this->assertTrue($newNode->isNew); + $this->assertSame('new_column italics', $newNode->classes); + $this->assertSame(['image' => 'b_column_add', 'title' => 'New'], $newNode->icon); + $this->assertSame( + [ + 'text' => [ + 'route' => '/table/add-field', + 'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null], + ], + 'icon' => [ + 'route' => '/table/add-field', + 'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null], + ], + ], + $newNode->links, ); - $this->assertEquals('columns', $parent->realName); } }