. */ declare(strict_types=1); namespace App\Tests\Helpers; use App\Helpers\Trees\TreeViewNode; use PHPUnit\Framework\TestCase; class TreeViewNodeTest extends TestCase { /** * @var TreeViewNode */ protected $node1; /** * @var TreeViewNode */ protected $node2; protected function setUp(): void { $sub_nodes = []; $sub_nodes[] = new TreeViewNode('Subnode 1'); $sub_sub_nodes[] = []; $sub_sub_nodes[] = new TreeViewNode('Sub Subnode 1'); $sub_sub_nodes[] = new TreeViewNode('Sub Subnode 2'); $sub_nodes[] = new TreeViewNode('Subnode 2'); //Init node1 with default arguments; $this->node1 = new TreeViewNode('Name'); //Node 2 gets values for all arguments $this->node2 = new TreeViewNode('Name', 'www.foo.bar', $sub_nodes); } public function testConstructor(): void { //A node without things should have null values on its properties: $this->assertNull($this->node1->getHref()); $this->assertNull($this->node1->getNodes()); $this->assertSame('Name', $this->node1->getText()); //The second node must have the given things as properties. $this->assertSame('Name', $this->node2->getText()); $this->assertSame('www.foo.bar', $this->node2->getHref()); $this->assertNotEmpty($this->node2->getNodes()); } }