function testSetCompare() { $tree = new AvlTree(); $tree->setCompare(function ($a, $b) { if ($a < $b) { return 1; } elseif ($b < $a) { return -1; } else { return 0; } }); $tree->add(1); $tree->add(2); $tree->add(0); $binary = $tree->toBinaryTree(); $this->assertInstanceOf('Collections\\BinaryTree', $binary); $this->assertNotNull($binary->left()); $this->assertEquals(2, $binary->left()->value()); $this->assertNotNull($binary->right()); $this->assertEquals(0, $binary->right()->value()); }