Skip to content

Commit 309c466

Browse files
committed
Add validating test
1 parent abc599a commit 309c466

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tests/unit/Codeception/Module/RestTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ public function testSeeResponseJsonXpathEvaluatesToBoolean()
573573
$this->setStubResponse('{"success": 1}');
574574
$this->module->seeResponseJsonXpathEvaluatesTo('count(//success) > 0', true);
575575
}
576-
576+
577577
public function testSeeResponseJsonXpathEvaluatesToNumber()
578578
{
579579
$this->setStubResponse('{"success": 1}');
@@ -585,7 +585,7 @@ public function testDontSeeResponseJsonXpathEvaluatesToBoolean()
585585
$this->setStubResponse('{"success": 1}');
586586
$this->module->dontSeeResponseJsonXpathEvaluatesTo('count(//success) > 0', false);
587587
}
588-
588+
589589
public function testDontSeeResponseJsonXpathEvaluatesToNumber()
590590
{
591591
$this->setStubResponse('{"success": 1}');
@@ -647,7 +647,7 @@ public function testHaveServerParameter()
647647
* @dataProvider schemaAndResponse
648648
*/
649649

650-
public function testSeeResponseIsValidOnJsonSchemachesJsonSchema(string $schema, string $response, bool $outcome, string $error)
650+
public function testSeeResponseIsValidOnJsonSchemaMatchesJsonSchema(string $schema, string $response, bool $outcome, string $error)
651651
{
652652
$response = file_get_contents(codecept_data_dir($response));
653653
$this->setStubResponse($response);
@@ -660,7 +660,7 @@ public function testSeeResponseIsValidOnJsonSchemachesJsonSchema(string $schema,
660660
$this->module->seeResponseIsValidOnJsonSchema(codecept_data_dir($schema));
661661
}
662662

663-
public function testSeeResponseIsValidOnJsonSchemachesJsonSchemaString()
663+
public function testSeeResponseIsValidOnJsonSchemaMatchesJsonSchemaString()
664664
{
665665
$this->setStubResponse('{"name": "john", "age": 20}');
666666
$this->module->seeResponseIsValidOnJsonSchemaString('{"type": "object"}');
@@ -676,6 +676,14 @@ public function testSeeResponseIsValidOnJsonSchemachesJsonSchemaString()
676676
$this->module->seeResponseIsValidOnJsonSchemaString(json_encode($schema, JSON_THROW_ON_ERROR));
677677
}
678678

679+
public function testSeeResponseIsInvalidOnJsonSchemaMatchesJsonSchemaString()
680+
{
681+
$this->setStubResponse('{"name": null, "age": 20}');
682+
$this->expectExceptionMessage("[Property: 'name'] NULL value found, but a string is required");
683+
$this->shouldFail();
684+
$this->module->seeResponseIsValidOnJsonSchemaString('{"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "integer"}}}');
685+
}
686+
679687
/**
680688
* @dataProvider configAndRequestUrls
681689
*/

0 commit comments

Comments
 (0)