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); }
/** * @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()); }