Skip to content

Commit

Permalink
Add an auto review test for the annotations (webmozarts#133)
Browse files Browse the repository at this point in the history
And also fix the one issue found by the test
  • Loading branch information
BackEndTea authored Oct 15, 2019
1 parent a296d8a commit 5f69d7d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public static function integer($value, $message = '')
*
* @param mixed $value
* @param string $message
*
* @throws InvalidArgumentException
*/
public static function integerish($value, $message = '')
{
Expand Down
44 changes: 41 additions & 3 deletions tests/ProjectCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,58 @@ public function testIsInReadme($method)
);
}

/**
* @dataProvider provideMethods
*
* @param ReflectionMethod $method
*/
public function testHasThrowsAnnotation($method)
{
$doc = $method->getDocComment();

$this->assertNotFalse(
$doc,
sprintf(
'Expected a doc comment on the "%s" method, but none found',
$method->getName()
)
);

$this->assertContains(
'@throws InvalidArgumentException',
$doc,
sprintf(
'Expected method "%s" to have an @throws InvalidArgumentException annotation, but none found',
$method->getName()
)
);

}

/**
* @return array
*/
public function providesMethodNames()
{
return array_map(function($value) {
return array($value->getName());
}, $this->getMethods());
}

/**
* @return array
*/
public function provideMethods()
{
return array_map(function($value) {
return array($value);
}, $this->getMethodNames());
}, $this->getMethods());
}

/**
* @return array
*/
private function getMethodNames()
private function getMethods()
{
static $methods;

Expand All @@ -108,7 +146,7 @@ private function getMethodNames()
if (strpos($methodName, '__') === 0) {
continue;
}
$methods[] = $methodName;
$methods[] = $rcMethod;
}

return $methods;
Expand Down

0 comments on commit 5f69d7d

Please sign in to comment.