/** * @dataProvider getTestSignatures * * @param string $signature The signature to test * @param bool $valid Whether the given signature is expected to * be valid. * @param string $expected_name The method name that is expected from this * signature * @param string $expected_return The return type that is expected from this * signature * @param bool $has_params whether this signature features parameters. * @param string $description The short description mentioned in the * signature. * * @return void */ public function testConstruct($signature, $valid, $expected_name, $expected_return, $has_params, $description) { ob_start(); $tag = new MethodTag('method', $signature); $stdout = ob_get_clean(); $this->assertSame($valid, empty($stdout), 'No error should have been output if the signature is valid'); if (!$valid) { return; } $this->assertEquals($expected_name, $tag->getMethodName()); $this->assertEquals($expected_return, $tag->getType()); $this->assertEquals($description, $tag->getDescription()); $this->assertSame($has_params, (bool) (count($tag->getArguments()) > 0), 'Number of found arguments should exceed 0'); }
/** * @param string $signature The signature to test. * @param bool $valid Whether the given signature is expected to * be valid. * @param string $expected_name The method name that is expected from this * signature. * @param string $expected_return The return type that is expected from this * signature. * @param bool $paramCount Number of parameters in the signature. * @param string $description The short description mentioned in the * signature. * * @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag * @dataProvider getTestSignatures * * @return void */ public function testConstruct($signature, $valid, $expected_name, $expected_return, $expected_isStatic, $paramCount, $description) { ob_start(); $tag = new MethodTag('method', $signature); $stdout = ob_get_clean(); $this->assertSame($valid, empty($stdout), 'No error should have been output if the signature is valid'); if (!$valid) { return; } $this->assertEquals($expected_name, $tag->getMethodName()); $this->assertEquals($expected_return, $tag->getType()); $this->assertEquals($description, $tag->getDescription()); $this->assertEquals($expected_isStatic, $tag->isStatic()); $this->assertCount($paramCount, $tag->getArguments()); }