Example #1
0
 /**
  * @return bool
  */
 public function hasDefaultValue()
 {
     return $this->gClass->hasDefaultValue($this);
 }
Example #2
0
    public function testPropertyCreation()
    {
        $gClass = new GClass('TestClass');
        // private $name;
        $name = $gClass->createProperty('name', GProperty::MODIFIER_PRIVATE);
        $this->assertInstanceOf('Psc\\Code\\Generate\\GProperty', $name);
        $this->assertTrue($name->isPrivate());
        $this->assertEquals('name', $name->getName());
        // hihi
        // protected $label = NULL;
        $label = $gClass->createProperty('label', GProperty::MODIFIER_PROTECTED, NULL);
        $this->assertInstanceOf('Psc\\Code\\Generate\\GProperty', $label);
        $this->assertTrue($label->isProtected());
        $this->assertEquals('label', $label->getName());
        $this->assertEquals(NULL, $label->getDefaultValue());
        $this->assertTrue($label->hasDefaultValue());
        $gClass->removeDefaultValue($label);
        $this->assertFalse($label->hasDefaultValue());
        // protected $label = 'datgleischewiename';
        $this->assertInstanceOf('Psc\\Code\\Generate\\GProperty', $label->setDefaultValue('datgleischewiename'));
        $this->assertEquals('datgleischewiename', $label->getDefaultValue());
        $this->assertTrue($gClass->hasDefaultValue($label));
        // public $unsafe;
        $unsafe = $gClass->createProperty('unsafe', GProperty::MODIFIER_PUBLIC);
        $this->assertInstanceOf('Psc\\Code\\Generate\\GProperty', $unsafe);
        $this->assertTrue($unsafe->isPublic());
        $this->assertFalse($unsafe->hasDefaultValue());
        $this->assertFalse($gClass->hasDefaultValue($unsafe));
        $classCode = <<<'CLASS_END'
class TestClass {
  
  private $name;
  
  protected $label = 'datgleischewiename';
  
  public $unsafe;
}
CLASS_END;
        $this->assertEquals($classCode, $gClass->php());
    }