Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karser committed Jan 20, 2025
1 parent cdf799d commit c038d1a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ReCaptcha/ReCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ReCaptcha
*/
public function __construct(?string $secret, ?RequestMethod $requestMethod = null)
{
if (null === $secret) {
if (!is_string($secret)) {
throw new \RuntimeException('The provided secret must be a string');
}
if ('' === $secret) {
Expand Down
2 changes: 1 addition & 1 deletion ReCaptcha/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function fromJson($json)
{
$responseData = json_decode($json, true);

if (false === $responseData) {
if (null === $responseData) {
return new Response(false, array(ReCaptcha::E_INVALID_JSON));
}

Expand Down
3 changes: 0 additions & 3 deletions Tests/ReCaptcha/ReCaptchaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public static function invalidSecretProvider(): array
return [
[''],
[null],
[0],
[new \stdClass()],
[[]],
];
}

Expand Down
4 changes: 4 additions & 0 deletions Tests/ReCaptcha/RequestMethod/PostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ protected function assertCommonOptions(array $args)
}
}

namespace Karser\Recaptcha3Bundle\ReCaptcha\RequestMethod;

use Karser\Recaptcha3Bundle\Tests\ReCaptcha\RequestMethod\PostTest;

function file_get_contents()
{
if (PostTest::$assert) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ReCaptcha/RequestMethod/SocketPostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function testConnectionFailureReturnsError()

$socket->expects(self::once())
->method('fsockopen')
->willReturn(false);
->willReturn(null);
$ps = new SocketPost($socket);
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
self::assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}', $response);
Expand Down
35 changes: 17 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
colors="true" bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
>
<testsuites>
<testsuite name="KarserRecaptcha3Bundle Test Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">.</directory>
</include>
<exclude>
<directory>Resources</directory>
<directory>Tests</directory>
<directory>vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="KarserRecaptcha3Bundle Test Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">.</directory>
</include>
<exclude>
<directory>Resources</directory>
<directory>Tests</directory>
<directory>vendor</directory>
</exclude>
</source>
</phpunit>

0 comments on commit c038d1a

Please sign in to comment.