Skip to content

Commit 135bfbe

Browse files
committed
tests fixed
1 parent c2b7a77 commit 135bfbe

File tree

6 files changed

+10
-17
lines changed

6 files changed

+10
-17
lines changed

src/Structure/ClassStructure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function makeSchema()
1818
$schema = new Schema();
1919
$properties = new Properties();
2020
static::setUpProperties($properties, $schema);
21-
$schema->setConstraint(new Type(ObjectType::TYPE));
21+
$schema->setConstraint(new Type(ObjectType::TYPE, $schema));
2222
$schema->setConstraint($properties);
2323
return $schema;
2424
}

src/Types/StringType.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ class StringType extends AbstractType
99

1010
public function import($data)
1111
{
12-
// TODO: Implement import() method.
12+
$this->validate($data);
13+
return $data;
1314
}
1415

1516
public function export($data)
1617
{
17-
// TODO: Implement export() method.
18+
$this->validate($data);
19+
return $data;
1820
}
1921

2022
protected function validate($data)

tests/src/ClassStructure/ClassStructureTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testSample()
3232
public function testSampleInvalid()
3333
{
3434
$schema = SampleStructure::makeSchema();
35-
$this->setExpectedException(get_class(new Exception()), 'Validation failed (Properties:recursion->Properties:propOne)');
35+
$this->setExpectedException(get_class(new Exception()), 'String required (Properties:recursion->Properties:propOne)');
3636
$schema->import(array(
3737
'propOne' => '1',
3838
'propTwo' => 2,

tests/src/Helper/SampleStructure.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class SampleStructure extends ClassStructure
2020
*/
2121
public static function setUpProperties($properties, Schema $schema)
2222
{
23-
$properties->propOne = StringType::create();
24-
$properties->propTwo = IntegerType::create();
23+
$properties->propOne = StringType::makeSchema();
24+
$properties->propTwo = IntegerType::makeSchema();
2525
$properties->recursion = $schema;
2626
}
2727
}

tests/src/Schema/ParentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testParent()
5757
public function testInvalidImport()
5858
{
5959
$schema = $this->deepSchema();
60-
$this->setExpectedException(get_class(new Exception()), 'Validation failed (Properties:level1->Properties:level2->Properties:level3)',
60+
$this->setExpectedException(get_class(new Exception()), 'Integer required (Properties:level1->Properties:level2->Properties:level3)',
6161
Exception::INVALID_VALUE);
6262
try {
6363
$object = $schema->import(array(

tests/src/StringTest.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88

99
class StringTest extends \PHPUnit_Framework_TestCase
1010
{
11-
public function testString()
12-
{
13-
$schema = StringType::makeSchema();
14-
15-
$this->assertFalse($schema->isValid(123));
16-
$this->assertTrue($schema->isValid('aaa'));
17-
}
18-
19-
2011
public function testStringSchema()
2112
{
2213
$schema = StringType::makeSchema();
@@ -26,7 +17,7 @@ public function testStringSchema()
2617
public function testStringSchemaException()
2718
{
2819
$schema = StringType::makeSchema();
29-
$this->setExpectedException(get_class(new Exception), 'Validation failed');
20+
$this->setExpectedException(get_class(new Exception), 'String required');
3021
$schema->import(123);
3122
}
3223

0 commit comments

Comments
 (0)