public function testReadTreeMessage() { $binary = $this->getProtoContent('tree.bin'); $root = Tree\Node::fromStream($binary); $this->assertInstanceOf(Tree\Node::CLASS, $root); $this->assertCount(2, $root->getChildrenList()); $this->assertEquals($root->getPath(), '/Users'); $node1 = $root->getChildrenList()[0]; $node2 = $root->getChildrenList()[1]; $this->assertInstanceOf(Tree\Node::CLASS, $node1); $this->assertInstanceOf(Tree\Node::CLASS, $node2); $this->assertEquals('/Users/fabio', $node1->getPath()); $this->assertEquals('/Users/admin', $node2->getPath()); $this->assertInstanceOf(Tree\Node::CLASS, $node1->getParent()); $this->assertInstanceOf(Tree\Node::CLASS, $node2->getParent()); $this->assertEquals('/Users', $node1->getParent()->getPath()); $this->assertEquals('/Users', $node2->getParent()->getPath()); }
public function testFormatTreeMessage() { $root = new Tree\Node(); $admin = new Tree\Node(); $fabio = new Tree\Node(); $root->setPath('/Users'); $fabio->setPath('/Users/fabio'); $admin->setPath('/Users/admin'); // avoid recursion $parent = clone $root; $admin->setParent($parent); $fabio->setParent($parent); $root->addChildren($fabio); $root->addChildren($admin); $expected = $this->getProtoContent('tree.txt'); $actual = $root->__toString(); $this->assertEquals($expected, (string) $actual); }