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 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); }
public function testExceptionWhenTypeDoesNotExist() { $msg = 'Type outline "ThankfulOx" not found'; $this->setExpectedException('Wookieb\\ZorroDataSchema\\Exception\\TypeOutlineNotFoundException', $msg); $this->object->getTypeOutline('ThankfulOx'); }