DenverCoder1 / github-readme-streak-stats

🔥 Stay motivated and show off your contribution streak! 🌟 Display your total contributions, current streak, and longest streak on your GitHub profile README
https://streak-stats.demolab.com
MIT License
4.82k stars 750 forks source link

Tests failing on main branch #258

Closed donutboyy closed 2 years ago

donutboyy commented 2 years ago

Describe the bug composer test failing with the following summary:

Summary of non-successful tests:

Stats
 ✘ Valid username
   │
   │ TypeError: json_decode(): Argument #1 ($json) must be of type string, bool given     
   │
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:130        
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:166        
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:15
   │ <path-to-repo>\github-readme-streak-stats\tests\StatsTest.php:31   
   │

 ✘ Invalid username
   │
   │ Failed asserting that exception of type "TypeError" matches expected exception "InvalidArgumentException". Message was: "json_decode(): Argument #1 ($json) must be of type string, bool given" at
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:130        
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:166        
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:15
   │ <path-to-repo>\github-readme-streak-stats\tests\StatsTest.php:81   
   │ .
   │

 ✘ Organization name
   │
   │ Failed asserting that exception of type "TypeError" matches expected exception "InvalidArgumentException". Message was: "json_decode(): Argument #1 ($json) must be of type string, bool given" at
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:130        
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:166        
   │ <path-to-repo>\github-readme-streak-stats\src\stats.php:15
   │ <path-to-repo>\github-readme-streak-stats\tests\StatsTest.php:91   
   │ .
   │

ERRORS!
Tests: 26, Assertions: 1719, Errors: 1, Failures: 2.
Script ./vendor/bin/phpunit --testdox tests handling the test event returned with error code 2

To Reproduce Steps to reproduce the behavior:

  1. Have main branch checked out with no changes
  2. Run composer test

Additional context I'm on Windows 10 and running PHP 8.1.7 (cli)

DenverCoder1 commented 2 years ago

It seems that your computer is failing to send the curl request

image

Adding an if statement on line 129 of stats.php will prevent the TypeError and allow you to see more details about what error you're getting

    $response = curl_exec($ch);
+    if ($response === false) {
+        throw new AssertionError("curl_exec() failed: " . curl_error($ch));
+    }
    curl_close($ch);
    $obj = json_decode($response);
donutboyy commented 2 years ago

Thanks! It was an SSL certificate problem, just had to properly install the latest cacert.pem.