planetteamspeak / ts3phpframework

Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
https://www.planetteamspeak.com
GNU General Public License v3.0
212 stars 59 forks source link

Various PHPUnit fixes #175

Closed Sebbo94BY closed 1 year ago

Sebbo94BY commented 1 year ago

This fixes (nearly) all fatal errors / failures. I haven't touched the risky issues.

There is only one failure left on non-english systems, but I'm not sure how this can or should be fixed. 🤔

There was 1 failure:

1) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Transport\TCPTest::testConnectHostRefuseConnection Failed asserting that exception message 'Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte' contains 'Connection refused'.

The test expects the error message Connection refused, but on my local machine, it returns a very long and German text. Translated into English, the text would be Could not connect because the target computer refused to connect, so in general the correct exception message. 😅

This pull request depends on #174, so this should be merged first.

Local PHPUnit test result:

Sebastian@Sebastian-PC MINGW64 ~/Downloads/ts3phpframework (Various-PHPUnit-fixes)
$ php vendor/bin/phpunit
PHPUnit 9.6.3 by Sebastian Bergmann and contributors.

Warning:       No code coverage driver available

..R.RRRRRRRRRRR.........RRRRR..................................  63 / 114 ( 55%)
.........R..RR...................FR.............R..             114 / 114 (100%)

Time: 00:20.923, Memory: 10.00 MB

There was 1 failure:

1) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Transport\TCPTest::testConnectHostRefuseConnection
Failed asserting that exception message 'Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte' contains 'Connection refused'.

--

There were 22 risky tests:

1) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testConstructor
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:43

2) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testToLines
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:64

3) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testToTable
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:67

4) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testToArray
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:70

5) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testToAssocArray
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:73

6) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testToList
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:76

7) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testToObjectArray
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:79

8) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Adapter\ServerQuery\ReplyTest::testGetCommandString
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Adapter\ServerQuery\ReplyTest.php:82

18) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Helper\UriTest::testParseURI
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Helper\UriTest.php:77

19) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Helper\UriTest::testCheckHost
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Helper\UriTest.php:142

20) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Helper\UriTest::testCheckPort
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Helper\UriTest.php:147

21) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Transport\TCPTest::testDisconnectNoConnection
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Transport\TCPTest.php:126

22) PlanetTeamSpeak\TeamSpeak3Framework\Tests\Transport\UDPTest::testDisconnectNoConnection
This test did not perform any assertions

C:\Users\Sebastian\Downloads\ts3phpframework\tests\Transport\UDPTest.php:134

FAILURES!
Tests: 114, Assertions: 597, Failures: 1, Risky: 22.
Sebbo94BY commented 1 year ago

Finally. I hate CI/CD development. It's most of the time a trial-and-error thing. 😅

@ronindesign I could simply merge this, but I would appreciate it, when you could atleast review my code and unittest changes.

ronindesign commented 1 year ago

This is looking really great, thank you for your time and work on this PR!

This pull request depends on #174, so this should be merged first.

Looks like you merged 0e39749, a8cc7fd from #174 into this PR and close that one, but let me know if I'm missing something.

There is only one failure left on non-english systems, but I'm not sure how this can or should be fixed. 🤔

For the non-English error issue, I think how it fails currently is probably best possible scenario. CI/CD should be tested against English (as I'm not aware of any localization support otherwise.) And so when the local language is not Engilsh, it should be an annoying, but expected failure I suppose. It's unfortunate to not get green across the board, so maybe there might be a better long-term fix in the future.

Thanks again for the labor and contribution!

Sebbo94BY commented 1 year ago

Yeah, I've merged it - it made sense to combine them. :D

Yeah, regarding the localization, I thought about setting the language as first step in the respective function or something using e.g. https://www.php.net/manual/en/function.setlocale.php, but not sure. I've too less experience with PHPUnit tests regarding best practices.

No problem. You're welcome. :)