Skip to content

Commit bc8ead2

Browse files
committed
pushing legacy to the future!
1 parent 3f68cc5 commit bc8ead2

File tree

10 files changed

+42
-36
lines changed

10 files changed

+42
-36
lines changed

src/Schema.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ private function fail($message)
343343

344344
public function export($data)
345345
{
346+
throw new Exception('Implement me');
347+
346348
$result = $data;
347349
if ($this->ref !== null) {
348350
$result = $this->ref->getSchema()->export($data);

src/SchemaLoader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ protected function readSchemaDeeper($schemaArray, Schema $parentSchema = null)
131131
$additionalProperties = $schemaArray[self::ADDITIONAL_PROPERTIES];
132132
if ($additionalProperties instanceof \stdClass) {
133133
$schema->additionalProperties = $this->readSchemaDeeper($additionalProperties);
134-
} else {
134+
} elseif (is_bool($additionalProperties)) {
135135
$schema->additionalProperties = $additionalProperties;
136+
} else {
137+
throw new Exception('Object or boolean required for additionalProperties', Exception::INVALID_VALUE);
136138
}
137139
}
138140

tests/src/Naive/PropertiesTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public function testValid()
1616
)
1717
));
1818

19-
$data = array(
19+
20+
21+
$data = (object)array(
2022
'one' => 'aaa',
2123
'two' => 123,
2224
);

tests/src/PHPUnit/AdditionalPropertiesTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function testBasic()
1313
{
1414
$schemaData = array(
1515
'type' => 'object',
16-
'additionalProperties' => array(
16+
'additionalProperties' => (object)array(
1717
'type' => 'integer'
1818
),
1919
);
@@ -34,10 +34,10 @@ public function testRef()
3434
// $this->markTestSkipped('Not implemented');
3535
$schemaData = array(
3636
'type' => 'object',
37-
'additionalProperties' => array(
37+
'additionalProperties' => (object)array(
3838
'$ref' => '#/def'
3939
),
40-
'def' => array(
40+
'def' => (object)array(
4141
'type' => 'integer',
4242
),
4343
);
@@ -47,7 +47,7 @@ public function testRef()
4747
//print_r($schema);
4848

4949
$object = $schema->import(
50-
array('one' => 1, 'two' => 2)
50+
(object)array('one' => 1, 'two' => 2)
5151
);
5252

5353
$this->assertSame(1, $object->one);
@@ -59,22 +59,22 @@ public function testWithProperties()
5959

6060
$schemaData = array(
6161
'type' => 'object',
62-
'additionalProperties' => array(
62+
'additionalProperties' => (object)array(
6363
'$ref' => '#/def'
6464
),
6565
'properties' => array(
6666
'zero' => array(
6767
'type' => 'string',
6868
),
6969
),
70-
'def' => array(
70+
'def' => (object)array(
7171
'type' => 'integer',
7272
),
7373
);
7474

7575
$schema = SchemaLoader::create()->readSchema($schemaData);
7676
$object = $schema->import(
77-
array('zero' => '0', 'one' => 1, 'two' => 2)
77+
(object)array('zero' => '0', 'one' => 1, 'two' => 2)
7878
);
7979

8080
$this->assertSame('0', $object->zero);
@@ -88,9 +88,9 @@ public function testNonRootSchema()
8888
$schemaData = array(
8989
'type' => 'object',
9090
'properties' => array(
91-
'deeper' => array(
91+
'deeper' => (object)array(
9292
'type' => 'object',
93-
'additionalProperties' => array(
93+
'additionalProperties' => (object)array(
9494
'type' => 'integer'
9595
),
9696
)
@@ -102,8 +102,8 @@ public function testNonRootSchema()
102102
//print_r($schema);
103103

104104
$object = $schema->import(
105-
array(
106-
'deeper' => array('one' => 1, 'two' => 2)
105+
(object)array(
106+
'deeper' => (object)array('one' => 1, 'two' => 2)
107107
)
108108
);
109109

tests/src/PHPUnit/ClassStructure/ClassStructureTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public function testSample()
1212
{
1313
$schema = SampleStructure::makeSchema();
1414
//print_r($schema);
15-
$object = $schema->import(array(
15+
$object = $schema->import((object)array(
1616
'propOne' => '1',
1717
'propTwo' => 2,
18-
'recursion' => array(
18+
'recursion' => (object)array(
1919
'propOne' => '11',
2020
'propTwo' => 22,
2121
)
@@ -33,10 +33,10 @@ public function testSampleInvalid()
3333
{
3434
$schema = SampleStructure::makeSchema();
3535
$this->setExpectedException(get_class(new Exception()), 'String required at properties:recursion->properties:propOne');
36-
$schema->import(array(
36+
$schema->import((object)array(
3737
'propOne' => '1',
3838
'propTwo' => 2,
39-
'recursion' => array(
39+
'recursion' => (object)array(
4040
'propOne' => 11,
4141
'propTwo' => 22,
4242
)

tests/src/PHPUnit/RefTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testResolve()
2727
$loader = new SchemaLoader();
2828
$schema = $loader->readSchema($schemaData);
2929

30-
$import = $schema->import(array('one' => 123));
30+
$import = $schema->import((object)array('one' => 123));
3131
$this->assertSame(123, $import->one);
3232
}
3333

@@ -60,8 +60,8 @@ public function testRootResolve()
6060
$loader = new SchemaLoader();
6161
$schema = $loader->readSchema($schemaData);
6262

63-
$object = $schema->import(array(
64-
'two' => array(
63+
$object = $schema->import((object)array(
64+
'two' => (object)array(
6565
'one' => 123
6666
)
6767
)

tests/src/PHPUnit/ReimportTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class ReImportTest extends \PHPUnit_Framework_TestCase
1010

1111
public function testJsonSchema()
1212
{
13-
$data = file_get_contents(__DIR__ . '/../../res/json-schema.json');
14-
$data = json_decode($data, true);
13+
$data = file_get_contents(__DIR__ . '/../../../spec/json-schema.json');
14+
$data = json_decode($data);
1515
//print_r($data);
1616

1717
$schema = SchemaLoader::create()->readSchema($data);
@@ -22,8 +22,8 @@ public function testJsonSchema()
2222

2323
public function testDoubleImport()
2424
{
25-
$data = file_get_contents(__DIR__ . '/../../res/json-schema.json');
26-
$data = json_decode($data, true);
25+
$data = file_get_contents(__DIR__ . '/../../../spec/json-schema.json');
26+
$data = json_decode($data);
2727
//print_r($data);
2828

2929
$schema = SchemaLoader::create()->readSchema($data);

tests/src/PHPUnit/Schema/CreateTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public function testCreate()
2323
);
2424

2525
$schema->properties = $properties;
26-
$rawData = array(
26+
$rawData = (object)array(
2727
'stringValue' => 'abc',
28-
'one' => array(
29-
'two' => array(
28+
'one' => (object)array(
29+
'two' => (object)array(
3030
'three' => 3
3131
),
3232
),

tests/src/PHPUnit/Schema/ParentFixedTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ protected function deepSchema()
1818

1919
public function testImportClass()
2020
{
21-
$data = array(
22-
'level1' => array(
23-
'level2' => array(
21+
$data = (object)array(
22+
'level1' => (object)array(
23+
'level2' => (object)array(
2424
'level3' => 123 // integer required
2525
),
2626
),

tests/src/PHPUnit/Schema/ParentTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function testInvalidImport()
5757
$this->setExpectedException(get_class(new Exception()), 'Integer required at properties:level1->properties:level2->properties:level3',
5858
Exception::INVALID_VALUE);
5959
try {
60-
$object = $schema->import(array(
61-
'level1'=> array(
62-
'level2' =>array(
60+
$object = $schema->import((object)array(
61+
'level1'=> (object)array(
62+
'level2' =>(object)array(
6363
'level3' => 'abc' // integer required
6464
),
6565
),
@@ -75,9 +75,9 @@ public function testInvalidImport()
7575

7676
public function testImport()
7777
{
78-
$object = $this->deepSchema()->import(array(
79-
'level1'=> array(
80-
'level2' =>array(
78+
$object = $this->deepSchema()->import((object)array(
79+
'level1'=> (object)array(
80+
'level2' => (object)array(
8181
'level3' => 123 // integer required
8282
),
8383
),

0 commit comments

Comments
 (0)