/** * @return void * @covers \pdepend\reflection\api\StaticReflectionMethod * @group reflection * @group reflection::api * @group unittest */ public function testToStringReturnsExpectedResultForMethodWithParameters() { $class = new StaticReflectionClass('Foo', '', 0); $class->initFileName('/bar/Foo.php'); $method = new StaticReflectionMethod('foo', '', StaticReflectionMethod::IS_PUBLIC); $method->initDeclaringClass($class); $method->initStartLine(23); $method->initEndLine(42); $method->initParameters(array(new StaticReflectionParameter('x', 0), new StaticReflectionParameter('y', 1))); $actual = $method->__toString(); $expected = 'Method [ <user> public method foo ] {' . PHP_EOL . ' @@ /bar/Foo.php 23 - 42' . PHP_EOL . PHP_EOL . ' - Parameters [2] {' . PHP_EOL . ' Parameter #0 [ <required> $x ]' . PHP_EOL . ' Parameter #1 [ <required> $y ]' . PHP_EOL . ' }' . PHP_EOL . '}'; $this->assertEquals($expected, $actual); }
/** * @return void * @covers \pdepend\reflection\api\StaticReflectionClass * @group reflection * @group reflection::api * @group unittest */ public function testToStringReturnsExpectedResultForClassWithProperties() { $class = new StaticReflectionClass('Foo', '', 0); $class->initFileName('/bar/Foo.php'); $class->initStartLine(23); $class->initEndLine(42); $class->initProperties(array(new StaticReflectionProperty('_foo', '', StaticReflectionProperty::IS_PRIVATE))); $actual = $class->__toString(); $expected = 'Class [ <user> class Foo ] {' . PHP_EOL . ' @@ /bar/Foo.php 23-42' . PHP_EOL . PHP_EOL . ' - Constants [0] {' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . ' - Properties [1] {' . PHP_EOL . ' Property [ <default> private $_foo ]' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . ' - Methods [0] {' . PHP_EOL . ' }' . PHP_EOL . '}'; $this->assertEquals($expected, $actual); }