protected function setUp() { $this->schemaOutline = new SchemaOutline(); $this->object = new HoistClassDynamicTypeOutline($this->schemaOutline); $this->schemaOutline->addTypeOutline(new StringOutline()); $this->schemaOutline->addDynamicTypeOutline($this->object); }
public function testAddType() { $this->assertMethodChaining($this->object->addTypeOutline($this->type), 'addTypeOutline'); $this->assertSame($this->type, $this->object->getTypeOutline('OrnatePatient')); $this->assertTrue($this->object->hasTypeOutline('OrnatePatient')); $result = iterator_to_array($this->object); $this->assertSame($this->type, $result['OrnatePatient']); }
public function testBuildWithProvidedSchema() { $outline = new SchemaOutline(); $outline->addTypeOutline(new StringOutline()); $this->object->setSchemaOutlineBuilder(new SchemaOutlineBuilder($outline)); $expected = new Schema(); $expected->registerType('string', new StringType()); $this->prepareBuilder($expected); $this->assertEquals($expected, $this->object->build()); }
private function prepareLinker($useMockGenerator = true) { $outline = new SchemaOutline(); $outline->addTypeOutline(new StringOutline())->addTypeOutline(new BooleanOutline()); $implementation = new Implementation(); $this->object->registerTypeBuilder(new BasicTypesBuilder()); if ($useMockGenerator) { $mockTypeBuilder = $this->getMockForAbstractClass('Wookieb\\ZorroDataSchema\\Schema\\Builder\\TypeBuilders\\TypeBuilderInterface'); $mockTypeBuilder->expects($this->atLeastOnce())->method('isAbleToGenerate')->will($this->returnCallback(function ($value) { return $value instanceof BooleanOutline; })); $mockTypeBuilder->expects($this->once())->method('generate')->with($this->equalTo(new BooleanOutline()), $this->equalTo($implementation))->will($this->returnValue(new FloatType())); $this->object->registerTypeBuilder($mockTypeBuilder, 100); } return array($outline, $implementation); }