Skip to content

Commit

Permalink
Merge pull request #133 from MindscapeHQ/feature/php8-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill authored Jan 17, 2021
2 parents 6b0063b + f68e595 commit 1ac3953
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: php

dist: trusty
dist: xenial

php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'

cache:
directories:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"require-dev": {
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.0",
"estahn/phpunit-json-assertions": "^3"
"justinrainbow/json-schema": "^5.2"
},
"suggest": {
"ext-curl": "*"
Expand Down
10 changes: 6 additions & 4 deletions tests/RaygunClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

namespace Raygun4php\Tests;

use JsonSchema\Validator;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Raygun4php\RaygunClient;
use Raygun4php\RaygunMessage;
use Raygun4php\RaygunRequestMessage;
use Raygun4php\Interfaces\TransportInterface;
use Raygun4php\Tests\Stubs\TransportGetMessageStub;
use EnricoStahn\JsonAssert\Assert as JsonAssert;

class RaygunClientTest extends TestCase
{
use JsonAssert;

/**
* @var RaygunClient
*/
Expand Down Expand Up @@ -205,6 +203,10 @@ public function testValidateMessageJsonInTransportObj()
$client->SendException(new \Exception('test'));
$raygunMessage = $transportStub->getMessage();

$this->assertJsonMatchesSchemaString($this->jsonSchema, json_decode($raygunMessage->toJson()));
$data = json_decode($raygunMessage->toJson());

$schemaValidator = new Validator();
$schemaValidator->validate($data, $this->jsonSchema);
$this->assertTrue($schemaValidator->isValid());
}
}
10 changes: 6 additions & 4 deletions tests/RaygunMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
namespace Raygun4php\Tests;

use Exception;
use JsonSchema\Validator;
use PHPUnit\Framework\TestCase;
use Raygun4php\RaygunMessage;
use EnricoStahn\JsonAssert\Assert as JsonAssert;

class RaygunMessageTest extends TestCase
{
use JsonAssert;

/**
* json schema used to validate message json.
*
Expand Down Expand Up @@ -65,6 +63,10 @@ public function testMessageToJsonSchema()
$msg->build(new Exception('Test'));

$msgJson = $msg->toJson();
$this->assertJsonMatchesSchemaString($this->jsonSchema, json_decode($msgJson));
$data = json_decode($msgJson);

$schemaValidator = new Validator();
$schemaValidator->validate($data, $this->jsonSchema);
$this->assertTrue($schemaValidator->isValid());
}
}

0 comments on commit 1ac3953

Please sign in to comment.