public function testSimpleInterfaceToString() { $file = new PhpFileComponent('Foo'); $interface = new PhpInterfaceComponent('Foo', true, null, array('stdClass')); $interface->addAnnotationBlock('@var string')->addConstant('FOO', 'theValue')->addAnnotationBlock('@var string')->addConstant('BAR', 'theOtherValue')->addAnnotationBlock(new PhpAnnotationElement('var', 'int'))->addProperty('bar', 1)->addAnnotationBlock(new PhpAnnotationElement('var', 'bool'))->addPropertyElement(new PhpPropertyElement('sample', true))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useful'), new PhpAnnotationElement('date', '2012-03-01'), '@return mixed'))->addMethod('getMyValue', array(new PhpFunctionParameterElement('asString', true), 'unusedParameter'))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useless'), new PhpAnnotationElement('date', '2012-03-01'), '@return void'))->addMethod('uselessMethod', array(new PhpFunctionParameterElement('uselessParameter', null), 'unusedParameter')); $file->setNamespace('My\\Testing\\NamespaceName')->addUse('My\\Testing\\ParentNamespace\\Model')->addUse('My\\Testing\\ParentNamespace\\Repository')->addUse('My\\Testing\\ParentNamespace\\Generator')->addUse('My\\Testing\\ParentNamespace\\Foo', 'FooType', true)->addInterfaceComponent($interface); $this->assertSameContent(__FUNCTION__, $file); }
public function testSimpleToString() { $interface = new PhpInterfaceComponent('Foo', true, null, array('stdClass')); $interface->addAnnotationBlock('@var string')->addConstant('FOO', 'theValue')->addAnnotationBlock('@var string')->addConstant('BAR', 'theOtherValue')->addAnnotationBlock(new PhpAnnotationElement('var', 'int'))->addProperty('bar', 1)->addAnnotationBlock(new PhpAnnotationElement('var', 'bool'))->addPropertyElement(new PhpPropertyElement('sample', true))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useful'), new PhpAnnotationElement('date', '2012-03-01'), '@return mixed'))->addMethodElement(new PhpMethod('getMyValue', array(new PhpFunctionParameterElement('asString', true), 'unusedParameter')))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useless'), new PhpAnnotationElement('date', '2012-03-01'), '@return void'))->addMethod('uselessMethod', array(new PhpFunctionParameterElement('uselessParameter', null), 'unusedParameter')); $this->assertSameContent(__FUNCTION__, $interface); }
/** * @param PhpInterfaceComponent $interface * @return PhpFile */ public function addInterfaceComponent(PhpInterfaceComponent $interface) { $this->mainElement->addChild($interface->toString()); return $this; }