From abd19787a2126c08b9f26c378986f8c7a6bb4222 Mon Sep 17 00:00:00 2001 From: Max Jacobson Date: Tue, 21 Mar 2017 01:00:47 -0400 Subject: [PATCH] Avoid printing a php notice for each issue The interpreter wants us to do this `end` shenanigan. Getting this method under test actually _required_ us to avoid the notice, which is kind of cool. --- Category.php | 6 +++--- tests/CategoryTest.php | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/CategoryTest.php diff --git a/Category.php b/Category.php index 0c45c77..1cb4a8c 100644 --- a/Category.php +++ b/Category.php @@ -66,9 +66,9 @@ public static function categoryFor($checkName) public static function documentationFor($checkName) { - $rule = array_pop( - explode("/", $checkName) - ); + $checkNameParts = explode("/", $checkName); + end($checkNameParts); + $rule = array_pop($checkNameParts); $filePath = dirname(__FILE__) . "/content/" . strtolower($rule) . ".txt"; diff --git a/tests/CategoryTest.php b/tests/CategoryTest.php new file mode 100644 index 0000000..20ebd3e --- /dev/null +++ b/tests/CategoryTest.php @@ -0,0 +1,21 @@ +assertEquals("Security", $category); + } + + public function testDocumentationFor() + { + $documentation = Category::documentationFor("Design/EvalExpression"); + $this->assertContains("An eval-expression is untestable", $documentation); + } +}