/**
  * _init()
  *
  * This method will prepare the constant array for this class
  */
 protected function _init()
 {
     if (count(self::$_constants) == 0) {
         $reflect = new ReflectionClass(get_class($this));
         self::$_constants = $reflect->getConstants();
         unset($reflect);
     }
 }
Beispiel #2
0
 /**
  * @dataProvider dataSetTypeSetValueGenerate
  * @param string $type
  * @param mixed $value
  * @param string $code
  */
 public function testSetBogusTypeSetValueGenerateUseAutoDetection($type, $value, $code)
 {
     if ($type == 'constant') {
         return;
         // constant can only be detected explicitly
     }
     $defaultValue = new Zend_CodeGenerator_Php_Property_DefaultValue();
     $defaultValue->setType("bogus");
     $defaultValue->setValue($value);
     $this->assertEquals($code, $defaultValue->generate());
 }
Beispiel #3
0
    public function testPropertyDefaultValueCanHandleComplexArrayOfTypes()
    {
        $targetValue = array(5, 'one' => 1, 'two' => '2', array('foo', 'bar', array('baz1', 'baz2')), new Zend_CodeGenerator_Php_Property_DefaultValue(array('value' => 'PHP_EOL', 'type' => 'constant')));
        $expectedSource = <<<EOS
array(
        5,
        'one' => 1,
        'two' => '2',
        array(
            'foo',
            'bar',
            array(
                'baz1',
                'baz2'
                )
            ),
        PHP_EOL
        );
EOS;
        $propDefaultValue = new Zend_CodeGenerator_Php_Property_DefaultValue();
        $propDefaultValue->setValue($targetValue);
        $generatedTargetSource = $propDefaultValue->generate();
        $this->assertEquals($expectedSource, $generatedTargetSource);
    }