/** * @group ZF-11513 */ public function testAllowsClassConstantToHaveSameNameAsClassProperty() { $const = new Php\PhpProperty(); $const->setName('name')->setDefaultValue('constant')->setConst(true); $property = new Php\PhpProperty(); $property->setName('name')->setDefaultValue('property'); $codeGenClass = new Php\PhpClass(); $codeGenClass->setName('My_Class')->setProperties(array($const, $property)); $expected = <<<CODE class My_Class { const name = 'constant'; public \$name = 'property'; } CODE; $this->assertEquals( $expected, $codeGenClass->generate() ); }
/** * @group namespace */ public function testPassingANamespacedClassnameShouldGenerateAClassnameWithoutItsNamespace() { $codeGenClass = new Php\PhpClass(); $codeGenClass->setName('My\\Namespaced\\FunClass'); $received = $codeGenClass->generate(); $this->assertContains('class FunClass', $received, $received); }
/** * @group ZF-9602 */ public function testSetextendedclassShouldNotIgnoreNonEmptyClassnameOnGenerate() { $codeGenClass = new Php\PhpClass(); $codeGenClass->setName('MyClass')->setExtendedClass('ParentClass'); $expected = <<<CODE class MyClass extends ParentClass { } CODE; $this->assertEquals($expected, $codeGenClass->generate()); }