Skip to content

Commit d113909

Browse files
committed
Enable schema validation for the test suite
1 parent b7c6ad7 commit d113909

31 files changed

+79
-0
lines changed

tests/Constraints/AdditionalPropertiesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class AdditionalPropertiesTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/ArraysTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class ArraysTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/BasicTypesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
class BasicTypesTest extends BaseTestCase
1313
{
14+
protected $schemaSpec = 'http://json-schema.org/draft-03/schema#';
15+
protected $validateSchema = true;
16+
1417
public function getInvalidTests()
1518
{
1619
return array(

tests/Constraints/CoerciveTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
class CoerciveTest extends BasicTypesTest
1919
{
20+
protected $schemaSpec = 'http://json-schema.org/draft-03/schema#';
21+
protected $validateSchema = true;
22+
2023
/**
2124
* @dataProvider getValidCoerceTests
2225
*/

tests/Constraints/DependenciesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
class DependenciesTest extends BaseTestCase
1313
{
14+
protected $schemaSpec = 'http://json-schema.org/draft-03/schema#';
15+
protected $validateSchema = true;
16+
1417
public function getInvalidTests()
1518
{
1619
return array(

tests/Constraints/DisallowTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111

1212
class DisallowTest extends BaseTestCase
1313
{
14+
// schemas in these tests look like draft-03, but the 'disallow' patterns provided are in
15+
// violation of the spec - 'disallow' as defined in draft-03 accepts the same values as the
16+
// 'type' option, and cannot take arbitrary patterns. The implementation in this library is
17+
// probably deliberate, but noting that it's invalid, schema validation has been disabled
18+
// for these tests. The 'disallow' option was removed permanently in draft-04.
19+
protected $schemaSpec = 'http://json-schema.org/draft-03/schema#';
20+
protected $validateSchema = false;
21+
1422
public function getInvalidTests()
1523
{
1624
return array(

tests/Constraints/DivisibleByTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class DivisibleByTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/EnumTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
class EnumTest extends BaseTestCase
1313
{
14+
protected $schemaSpec = 'http://json-schema.org/draft-03/schema#';
15+
protected $validateSchema = true;
16+
1417
public function getInvalidTests()
1518
{
1619
return array(

tests/Constraints/ExtendsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
class ExtendsTest extends BaseTestCase
1313
{
14+
protected $schemaSpec = 'http://json-schema.org/draft-03/schema#';
15+
protected $validateSchema = true;
16+
1417
public function getInvalidTests()
1518
{
1619
return array(

tests/Constraints/FormatTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
class FormatTest extends BaseTestCase
1515
{
16+
protected $validateSchema = true;
17+
1618
public function setUp()
1719
{
1820
date_default_timezone_set('UTC');

tests/Constraints/LongArraysTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
class LongArraysTest extends VeryBaseTestCase
1717
{
18+
protected $validateSchema = true;
19+
1820
public function testLongStringArray()
1921
{
2022
$schema =

tests/Constraints/MinItemsMaxItemsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class MinItemsMaxItemsTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/MinLengthMaxLengthMultiByteTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class MinLengthMaxLengthMultiByteTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
protected function setUp()
1517
{
1618
if (!extension_loaded('mbstring')) {

tests/Constraints/MinLengthMaxLengthTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class MinLengthMaxLengthTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/MinMaxPropertiesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class MinMaxPropertiesTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
/**
1517
* {@inheritdoc}
1618
*/

tests/Constraints/MinimumMaximumTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class MinimumMaximumTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/NotTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class NotTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/NumberAndIntegerTypesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class NumberAndIntegerTypesTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/OfPropertiesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
class OfPropertiesTest extends BaseTestCase
1515
{
16+
protected $validateSchema = true;
17+
1618
public function getValidTests()
1719
{
1820
return array(

tests/Constraints/PatternPropertiesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class PatternPropertiesTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/PatternTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class PatternTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/PointerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
class PointerTest extends \PHPUnit_Framework_TestCase
1515
{
16+
protected $validateSchema = true;
17+
1618
public function testVariousPointers()
1719
{
1820
$schema = array(

tests/Constraints/ReadOnlyTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class ReadOnlyTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
//is readonly really required?

tests/Constraints/RequireTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class RequireTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/RequiredPropertyTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
class RequiredPropertyTest extends BaseTestCase
1616
{
17+
// Most tests are draft-03 compliant, but some tests are draft-04, or mix draft-03 and
18+
// draft-04 syntax within the same schema. Unfortunately, draft-03 and draft-04 required
19+
// definitions are incompatible, so disabling schema validation for these tests.
20+
protected $schemaSpec = 'http://json-schema.org/draft-03/schema#';
21+
protected $validateSchema = false;
22+
1723
public function testErrorPropertyIsPopulatedForRequiredIfMissingInInput()
1824
{
1925
$validator = new UndefinedConstraint();

tests/Constraints/SelfDefinedSchemaTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313

1414
class SelfDefinedSchemaTest extends BaseTestCase
1515
{
16+
protected $validateSchema = true;
17+
1618
public function getInvalidTests()
1719
{
1820
return array(
1921
array(
2022
'{
2123
"$schema": {
24+
"$schema": "http://json-schema.org/draft-04/schema#",
2225
"properties": {
2326
"name": {
2427
"type": "string"
@@ -44,6 +47,7 @@ public function getValidTests()
4447
array(
4548
'{
4649
"$schema": {
50+
"$schema": "http://json-schema.org/draft-04/schema#",
4751
"properties": {
4852
"name": {
4953
"type": "string"

tests/Constraints/TupleTypingTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class TupleTypingTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/UnionTypesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class UnionTypesTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/UnionWithNullValueTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class UnionWithNullValueTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/UniqueItemsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class UniqueItemsTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

tests/Constraints/WrongMessagesFailingTestCaseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class WrongMessagesFailingTestCaseTest extends BaseTestCase
1313
{
14+
protected $validateSchema = true;
15+
1416
public function getInvalidTests()
1517
{
1618
return array(

0 commit comments

Comments
 (0)