11<?php
22
3- /*
4- * By adding type hints and enabling strict type checking, code can become
5- * easier to read, self-documenting and reduce the number of potential bugs.
6- * By default, type declarations are non-strict, which means they will attempt
7- * to change the original type to match the type specified by the
8- * type-declaration.
9- *
10- * In other words, if you pass a string to a function requiring a float,
11- * it will attempt to convert the string value to a float.
12- *
13- * To enable strict mode, a single declare directive must be placed at the top
14- * of the file.
15- * This means that the strictness of typing is configured on a per-file basis.
16- * This directive not only affects the type declarations of parameters, but also
17- * a function's return type.
18- *
19- * For more info review the Concept on strict type checking in the PHP track
20- * <link>.
21- *
22- * To disable strict typing, comment out the directive below.
23- */
24-
253declare (strict_types=1 );
264
275class BinarySearchTreeTest extends PHPUnit \Framework \TestCase
@@ -31,12 +9,20 @@ public static function setUpBeforeClass(): void
319 require_once 'BinarySearchTree.php ' ;
3210 }
3311
12+ /**
13+ * uuid e9c93a78-c536-4750-a336-94583d23fafa
14+ * @testdox data is retained
15+ */
3416 public function testDataIsRetained (): void
3517 {
3618 $ tree = new BinarySearchTree (4 );
3719 $ this ->assertEquals (4 , $ tree ->data );
3820 }
3921
22+ /**
23+ * uuid 7a95c9e8-69f6-476a-b0c4-4170cb3f7c91
24+ * @testdox smaller number at left node
25+ */
4026 public function testSmallNumberAtLeftNode (): void
4127 {
4228 $ tree = new BinarySearchTree (4 );
@@ -46,6 +32,10 @@ public function testSmallNumberAtLeftNode(): void
4632 $ this ->assertEquals (2 , $ tree ->left ->data );
4733 }
4834
35+ /**
36+ * uuid 22b89499-9805-4703-a159-1a6e434c1585
37+ * @testdox same number at left node
38+ */
4939 public function testSameNumberLeftNodes (): void
5040 {
5141 $ tree = new BinarySearchTree (4 );
@@ -55,6 +45,10 @@ public function testSameNumberLeftNodes(): void
5545 $ this ->assertEquals (4 , $ tree ->left ->data );
5646 }
5747
48+ /**
49+ * uuid 2e85fdde-77b1-41ed-b6ac-26ce6b663e34
50+ * @testdox greater number at right node
51+ */
5852 public function testGreaterNumberRightNode (): void
5953 {
6054 $ tree = new BinarySearchTree (4 );
@@ -64,6 +58,10 @@ public function testGreaterNumberRightNode(): void
6458 $ this ->assertEquals (5 , $ tree ->right ->data );
6559 }
6660
61+ /**
62+ * uuid dd898658-40ab-41d0-965e-7f145bf66e0b
63+ * @testdox can create complex tree
64+ */
6765 public function testCreateComplexTree (): void
6866 {
6967 $ tree = new BinarySearchTree (4 );
@@ -83,13 +81,21 @@ public function testCreateComplexTree(): void
8381 $ this ->assertEquals (7 , $ tree ->right ->right ->data );
8482 }
8583
84+ /**
85+ * uuid 9e0c06ef-aeca-4202-b8e4-97f1ed057d56
86+ * @testdox can sort single number
87+ */
8688 public function testCanSortSingleNode (): void
8789 {
8890 $ tree = new BinarySearchTree (2 );
8991
9092 $ this ->assertEquals ([2 ], $ tree ->getSortedData ());
9193 }
9294
95+ /**
96+ * uuid 425e6d07-fceb-4681-a4f4-e46920e380bb
97+ * @testdox can sort if second number is smaller than first
98+ */
9399 public function testCanSortSmallerSecondNumber (): void
94100 {
95101 $ tree = new BinarySearchTree (2 );
@@ -98,6 +104,10 @@ public function testCanSortSmallerSecondNumber(): void
98104 $ this ->assertEquals ([1 , 2 ], $ tree ->getSortedData ());
99105 }
100106
107+ /**
108+ * uuid bd7532cc-6988-4259-bac8-1d50140079ab
109+ * @testdox can sort if second number is same as first
110+ */
101111 public function testCanSortSameNumbers (): void
102112 {
103113 $ tree = new BinarySearchTree (2 );
@@ -106,6 +116,10 @@ public function testCanSortSameNumbers(): void
106116 $ this ->assertEquals ([2 , 2 ], $ tree ->getSortedData ());
107117 }
108118
119+ /**
120+ * uuid b6d1b3a5-9d79-44fd-9013-c83ca92ddd36
121+ * @testdox can sort if second number is greater than first
122+ */
109123 public function testCanSortGreaterSecondNumber (): void
110124 {
111125 $ tree = new BinarySearchTree (2 );
@@ -114,6 +128,10 @@ public function testCanSortGreaterSecondNumber(): void
114128 $ this ->assertEquals ([2 , 3 ], $ tree ->getSortedData ());
115129 }
116130
131+ /**
132+ * uuid d00ec9bd-1288-4171-b968-d44d0808c1c8
133+ * @testdox can sort complex tree
134+ */
117135 public function testCanSortComplexTree (): void
118136 {
119137 $ tree = new BinarySearchTree (2 );
0 commit comments