From 0c964d1ed839266b8d7594fcd1458cb6c9f93a60 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Thu, 14 Sep 2017 09:41:11 +1200 Subject: [PATCH] Composer lint --- .gitignore | 1 + composer.json | 6 +++++- src/Admin/CommentAdmin.php | 13 +++++++++---- tests/CommentingControllerTest.php | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5df1b9b..037bd21 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .sass-cache +/.php_cs.cache diff --git a/composer.json b/composer.json index 4186bb9..6798eb3 100644 --- a/composer.json +++ b/composer.json @@ -16,13 +16,17 @@ "silverstripe/cms": "The SilverStripe Content Management System" }, "require-dev": { - "phpunit/PHPUnit": "~4.8" + "phpunit/PHPUnit": "^5.7" }, "extra": { "branch-alias": { "dev-master": "3.x-dev" } }, + "scripts": { + "lint": "phpcs src/ tests/", + "fix": "php-cs-fixer fix src/ && php-cs-fixer fix tests/" + }, "autoload": { "psr-4": { "SilverStripe\\Comments\\": "src/", diff --git a/src/Admin/CommentAdmin.php b/src/Admin/CommentAdmin.php index 3858c32..ddccd55 100644 --- a/src/Admin/CommentAdmin.php +++ b/src/Admin/CommentAdmin.php @@ -19,7 +19,6 @@ use SilverStripe\Security\Security; */ class CommentAdmin extends LeftAndMain implements PermissionProvider { - private static $url_segment = 'comments'; private static $url_rule = '/$Action'; @@ -97,13 +96,19 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider $fields = new FieldList( $root = new TabSet( 'Root', - new Tab('NewComments', _t('CommentAdmin.NewComments', 'New') . ' ' . $newCount, + new Tab( + 'NewComments', + _t('CommentAdmin.NewComments', 'New') . ' ' . $newCount, $newGrid ), - new Tab('ApprovedComments', _t('CommentAdmin.ApprovedComments', 'Approved') . ' ' . $approvedCount, + new Tab( + 'ApprovedComments', + _t('CommentAdmin.ApprovedComments', 'Approved') . ' ' . $approvedCount, $approvedGrid ), - new Tab('SpamComments', _t('CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount, + new Tab( + 'SpamComments', + _t('CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount, $spamGrid ) ) diff --git a/tests/CommentingControllerTest.php b/tests/CommentingControllerTest.php index f63d6ee..62f837a 100644 --- a/tests/CommentingControllerTest.php +++ b/tests/CommentingControllerTest.php @@ -143,7 +143,8 @@ class CommentingControllerTest extends FunctionalTest // comments sitewide $response = $this->get('comments/rss'); - $this->assertEquals(10, substr_count($response->getBody(), ""), "10 approved, non spam comments on page 1"); + $comment = "10 approved, non spam comments on page 1"; + $this->assertEquals(10, substr_count($response->getBody(), ""), $comment); $response = $this->get('comments/rss?start=10'); $this->assertEquals(4, substr_count($response->getBody(), ""), "3 approved, non spam comments on page 2");