Esempio n. 1
0
    public function testPropertyDefaultValueCanHandleComplexArrayOfTypes()
    {
        $targetValue = array(5, 'one' => 1, 'two' => '2', array('foo', 'bar', array('baz1', 'baz2')), new Php\PhpPropertyValue(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 Php\PhpPropertyValue();
        $propDefaultValue->setValue($targetValue);
        $generatedTargetSource = $propDefaultValue->generate();
        $this->assertEquals($expectedSource, $generatedTargetSource);
    }
Esempio n. 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 Php\PhpPropertyValue();
     $defaultValue->setType("bogus");
     $defaultValue->setValue($value);
     $this->assertEquals($code, $defaultValue->generate());
 }