Skip to content

Commit 8d17a06

Browse files
committed
Refactor test structure: Add PHPUnit tests for interfaces with strong typing and mocks
- Add tests for Comparable interface - Add tests for Countable interface - Add tests for Indexable interface - Add tests for Iterator interface - Add tests for Sortable interface - Add tests for Collection interface - Add tests for Serializable interface - Add tests for Heap interface - Add tests for IterableCollection interface - Add tests for Map interface - Add tests for Queue interface - Add tests for Stack interface - Add tests for Tree interface Organize test files into respective directories for Behavioral, DataStructure, Structural, and Structure
1 parent f8b4682 commit 8d17a06

28 files changed

+417
-377
lines changed

composer.lock

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DataStructure/Behavioral/Comparable.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
declare(strict_types=1);
44

5-
namespace KaririCode\Contract\Behavioral;
5+
namespace KaririCode\Contract\DataStructure\Behavioral;
66

77
/**
88
* Interface Comparable.
99
*
1010
* Defines the contract for objects that can be compared.
1111
*
12-
* @package KaririCode\Contract\Behavioral
1312
* @category Interfaces
13+
*
1414
* @author Walmir Silva <walmir.silva@kariricode.org>
1515
* @license MIT
16+
*
1617
* @see https://kariricode.org/
1718
*/
1819
interface Comparable
@@ -21,8 +22,9 @@ interface Comparable
2122
* Compares this object with the specified object for order.
2223
*
2324
* @param mixed $other The object to compare with
24-
* @return int A negative integer, zero, or a positive integer as this object
25-
* is less than, equal to, or greater than the specified object.
25+
*
26+
* @return int a negative integer, zero, or a positive integer as this object
27+
* is less than, equal to, or greater than the specified object
2628
*/
2729
public function compareTo(mixed $other): int;
2830
}

src/DataStructure/Behavioral/Countable.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
declare(strict_types=1);
44

5-
namespace KaririCode\Contract\Behavioral;
5+
namespace KaririCode\Contract\DataStructure\Behavioral;
66

77
/**
88
* Interface Countable.
99
*
1010
* Defines the contract for counting elements.
1111
*
12-
* @package KaririCode\Contract\Behavioral
1312
* @category Interfaces
13+
*
1414
* @author Walmir Silva <walmir.silva@kariricode.org>
1515
* @license MIT
16+
*
1617
* @see https://kariricode.org/
1718
*/
1819
interface Countable

src/DataStructure/Behavioral/Indexable.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
declare(strict_types=1);
44

5-
namespace KaririCode\Contract\Behavioral;
5+
namespace KaririCode\Contract\DataStructure\Behavioral;
66

77
/**
88
* Interface Indexable.
99
*
1010
* Defines the contract for indexed access to elements.
1111
*
12-
* @package KaririCode\Contract\Behavioral
1312
* @category Interfaces
13+
*
1414
* @author Walmir Silva <walmir.silva@kariricode.org>
1515
* @license MIT
16+
*
1617
* @see https://kariricode.org/
1718
*/
1819
interface Indexable
@@ -21,6 +22,7 @@ interface Indexable
2122
* Checks if an element exists at the given index.
2223
*
2324
* @param int $index The index to check
25+
*
2426
* @return bool True if the index exists, false otherwise
2527
*/
2628
public function contains(int $index): bool;
@@ -29,6 +31,7 @@ public function contains(int $index): bool;
2931
* Gets the element at the specified index.
3032
*
3133
* @param int $index The index of the element
34+
*
3235
* @return mixed The element at the specified index
3336
*/
3437
public function get(int $index): mixed;
@@ -38,14 +41,14 @@ public function get(int $index): mixed;
3841
*
3942
* @param int $index The index at which to set the element
4043
* @param mixed $element The element to set
41-
* @return void
4244
*/
4345
public function set(int $index, mixed $element): void;
4446

4547
/**
4648
* Removes the element at the specified index.
4749
*
4850
* @param int $index The index of the element to remove
51+
*
4952
* @return bool True if the element was removed, false otherwise
5053
*/
5154
public function remove(int $index): bool;

src/DataStructure/Behavioral/IterableCollection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace KaririCode\Contract\DataStructure;
6-
7-
use KaririCode\Contract\Behavioral\Iterator;
5+
namespace KaririCode\Contract\DataStructure\Behavioral;
86

97
/**
108
* Interface IterableCollection.

src/DataStructure/Behavioral/Iterator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
declare(strict_types=1);
44

5-
namespace KaririCode\Contract\Behavioral;
5+
namespace KaririCode\Contract\DataStructure\Behavioral;
66

77
/**
88
* Interface Iterator.
99
*
1010
* Defines the contract for iterating over a collection of elements.
1111
*
12-
* @package KaririCode\Contract\Behavioral
1312
* @category Interfaces
13+
*
1414
* @author Walmir Silva <walmir.silva@kariricode.org>
1515
* @license MIT
16+
*
1617
* @see https://kariricode.org/
1718
*/
1819
interface Iterator

src/DataStructure/Behavioral/Sortable.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace KaririCode\Contract\Behavioral;
5+
namespace KaririCode\Contract\DataStructure\Behavioral;
66

77
/**
88
* Interface Sortable.
@@ -11,18 +11,17 @@
1111
* Classes implementing this interface should provide an implementation
1212
* for the sort method to allow sorting of their elements.
1313
*
14-
* @package KaririCode\Contract\Behavioral
1514
* @category Interfaces
15+
*
1616
* @author Walmir Silva <walmir.silva@kariricode.org>
1717
* @license MIT
18+
*
1819
* @see https://kariricode.org/
1920
*/
2021
interface Sortable
2122
{
2223
/**
2324
* Sorts the elements of the class.
24-
*
25-
* @return void
2625
*/
2726
public function sort(): void;
2827
}

0 commit comments

Comments
 (0)