| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 66 | public function testBlogSave() { |
||
| 67 | // No Admin. |
||
| 68 | self::$ci->blogger->setBlog("test_blog"); |
||
| 69 | $_POST["action"] = "save"; |
||
| 70 | $_POST["title"] = "Hello Title"; |
||
| 71 | $_POST["editor"] = "The Quick Brown Fox Jumped over the Lazy Dog."; |
||
| 72 | $this->assertEquals(self::$ci->blogger->savePost(), Blogger::CREATE); |
||
| 73 | $_POST["editor"] = "The Quick Brown Fox Jumped over the Lazy Dog. Again."; |
||
| 74 | $_POST["id"] = 1; |
||
| 75 | $this->assertEquals(self::$ci->blogger->savePost(), Blogger::EDIT); |
||
| 76 | $this->assertTrue(self::$ci->blogger->renderPost("Hello-Title", null)); |
||
| 77 | $post = self::$ci->blogger->getPost("Hello-Title", false); |
||
| 78 | $this->assertTrue(is_array($post)); |
||
| 79 | $this->assertArrayHasKey("id", $post); |
||
| 80 | $this->assertArrayHasKey("title", $post); |
||
| 81 | $this->assertArrayHasKey("content", $post); |
||
| 82 | $this->assertArrayHasKey("published", $post); |
||
| 83 | $this->assertArrayHasKey("date_published", $post); |
||
| 84 | $this->assertArrayHasKey("slug", $post); |
||
| 85 | $this->assertEquals(1, $post["id"], "Assert Post ID"); |
||
| 86 | $this->assertEquals("Hello Title", $post["title"], "Assert Post Title"); |
||
| 87 | $this->assertEquals("The Quick Brown Fox Jumped over the Lazy Dog. Again.", $post["content"]); |
||
| 88 | $this->assertEquals("Hello-Title", $post["slug"]); |
||
| 89 | $this->assertEquals(0, $post["published"]); |
||
| 90 | $this->assertEquals(null, $post["date_published"]); |
||
| 91 | $_POST["action"] = "publish"; |
||
| 92 | $this->assertEquals(self::$ci->blogger->savePost(), Blogger::PUBLISH); |
||
| 93 | $post = self::$ci->blogger->getPost("Hello-Title", false); |
||
| 94 | $this->assertTrue(is_array($post)); |
||
| 95 | $this->assertEquals(1, $post["published"]); |
||
| 96 | $this->assertNotEquals(null, $post["date_published"]); |
||
| 97 | $_POST["action"] = "createAndPublish"; |
||
| 98 | $_POST["title"] = "Hello Title 2"; |
||
| 99 | $_POST["editor"] = "Create and Published Post."; |
||
| 100 | unset($_POST["id"]); |
||
| 101 | $this->assertEquals(Blogger::CREATE_AND_PUBLISH, self::$ci->blogger->savePost()); |
||
| 102 | $post = self::$ci->blogger->getPost("Hello-Title-2", false); |
||
| 103 | $this->assertTrue(is_array($post)); |
||
| 104 | $this->assertArrayHasKey("id", $post); |
||
| 105 | $this->assertArrayHasKey("title", $post); |
||
| 106 | $this->assertArrayHasKey("content", $post); |
||
| 107 | $this->assertArrayHasKey("published", $post); |
||
| 108 | $this->assertArrayHasKey("date_published", $post); |
||
| 109 | $this->assertArrayHasKey("slug", $post); |
||
| 110 | $this->assertEquals(2, $post["id"], "Assert Post ID"); |
||
| 111 | $this->assertEquals("Hello Title 2", $post["title"], "Assert Post Title"); |
||
| 112 | $this->assertEquals("Create and Published Post.", $post["content"]); |
||
| 113 | $this->assertEquals("Hello-Title-2", $post["slug"]); |
||
| 114 | $this->assertEquals(1, $post["published"]); |
||
| 115 | $this->assertNotEquals(null, $post["date_published"]); |
||
| 116 | $this->assertEquals(Blogger::ABORT, self::$ci->blogger->savePost(), "No 2 blog posts can have the same title."); |
||
| 117 | } |
||
| 138 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths