TheAlgorithms / PHP

All Algorithms implemented in PHP
MIT License
2.14k stars 467 forks source link

[PHPUnit testing]: Sorting tests are not running #127

Closed anamarijapapic closed 1 year ago

anamarijapapic commented 1 year ago

The PHPUnit CLI test runner doesn't execute test methods from the SortingTests.php file.

This behavior is expected because the PHPUnit command-line test runner, when directed to a directory (in this project's case, tests), searches for *Test.php files, and the file SortingTests.php ends with *Tests.php.

To resolve this issue and have PHPUnit run the sorting tests, the file should be renamed from SortingTests.php to SortingTest.php.

Current test execution and output:

To run tests locally and in the CI script, the project uses the composer test Composer script (a shortcut for the vendor/bin/phpunit tests command), which returns the following output: OK (74 tests, 202 assertions).

While there are actually 95 tests and 221 assertions at the time of opening this issue!

When running the command vendor/bin/phpunit tests --testdox to generate a more detailed test report, it becomes evident that the sorting tests (located in SortingTests.php) are not being executed:

0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,10610209857723,17167680177565,27777890035288,44945570212853,72723460248141,117669030460994,190392490709135,308061521170129,498454011879264,806515533049393,1304969544928657,2111485077978050,3416454622906707,5527939700884757,8944394323791464,14472334024676221,23416728348467685,37889062373143906,61305790721611591,99194853094755497,160500643816367088,259695496911122585,420196140727489673,679891637638612258,1100087778366101931,1779979416004714189,2880067194370816120,4660046610375530309,7540113804746346429,1.2200160415122E+19,1.9740274219868E+19,3.194043463499E+19,5.1680708854858E+19,8.3621143489848E+19,1.3530185234471E+20,2.1892299583456E+20,956722026041PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

Ciphers
 ✔ Caesar cipher
 ✔ Xor cipher

Mono Alphabetic Cipher
 ✔ Mono alphabetic cipher

Morse Code
 ✔ Morse code cipher

Conversions
 ✔ Binary to decimal
 ✔ Decimal to binary
 ✔ Octal to decimal
 ✔ Decimal to octal
 ✔ Decimal to hex
 ✔ Hex to decimal
 ✔ Speed conversion

Singly Linked List
 ✔ Is palindrome with data set "IsPalindrome"
 ✔ Is palindrome with data set "IsPalindrome2"
 ✔ Is palindrome with data set "IsNotPalindrome"
 ✔ Is palindrome with data set "IsNotPalindrome2"
 ✔ Delete

Breadth First Search
 ✔ Breadth first search
 ✔ Breadth first search
 ✔ Breadth first search

Depth First Search
 ✔ Depth first search
 ✔ Depth first search
 ✔ Depth first search

Maths
 ✔ Factorial
 ✔ Is number armstrong
 ✔ Is number palindromic
 ✔ Is prime
 ✔ Absolute max
 ✔ Absolute min
 ✔ Perfect square
 ✔ Fast exponentiation
 ✔ Fibonacci series
 ✔ Neon number
 ✔ Fibonacci generator
 ✔ Mean
 ✔ Median
 ✔ Mode

Project Euler
 ✔ Problem 1
 ✔ Problem 2
 ✔ Problem 3
 ✔ Problem 4
 ✔ Problem 5
 ✔ Problem 6
 ✔ Problem 7
 ✔ Problem 8
 ✔ Problem 9
 ✔ Problem 10
 ✔ Problem 11

Searches
 ✔ Binary search iterative
 ✔ Binary search by recursion
 ✔ Binary search by recursion with empty list
 ✔ Binary search by recursion with one element list
 ✔ Binary search by recursion with two element list
 ✔ Binary search by recursion with three element list
 ✔ Fibonacci search
 ✔ Linear search
 ✔ Lower bound
 ✔ Upper bound
 ✔ Jump search
 ✔ Exponential search
 ✔ Ternary search iterative
 ✔ Ternary search by recursion
 ✔ Interpolation search

Array Keys Sort
 ✔ Array keys sort

Gnome Sort
 ✔ Gnome sort
 ✔ Gnome sort

Strings
 ✔ Is palindrome
 ✔ Count sentences
 ✔ Reverse string
 ✔ Reverse words
 ✔ Is anagram
 ✔ Max character
 ✔ Count vowels
 ✔ Count consonants
 ✔ Find distance

Time: 00:00.665, Memory: 70.02 MB

OK (74 tests, 202 assertions)