diff --git a/src/RbComment/Controller/CommentController.php b/src/RbComment/Controller/CommentController.php index 07da1d8..b3eee97 100644 --- a/src/RbComment/Controller/CommentController.php +++ b/src/RbComment/Controller/CommentController.php @@ -39,7 +39,7 @@ public function addAction() $comment->visible = $rbCommentConfig->default_visibility; // If akismet is enabled check for spam - if(($rbCommentConfig->akismet['enabled'] === true) && + if (($rbCommentConfig->akismet['enabled'] === true) && $this->isSpam($comment, $rbCommentConfig)) { $comment->spam = 1; $comment->visible = 0; @@ -49,7 +49,7 @@ public function addAction() $comment->id = $this->getCommentTable()->saveComment($comment); // Send email if active and not spam - if(($rbCommentConfig->email['notify'] === true) && + if (($rbCommentConfig->email['notify'] === true) && ($comment->spam === 0)) { $this->rbMailer($comment); } diff --git a/src/RbComment/View/Helper/Comment.php b/src/RbComment/View/Helper/Comment.php index af590c2..dfdf941 100644 --- a/src/RbComment/View/Helper/Comment.php +++ b/src/RbComment/View/Helper/Comment.php @@ -6,7 +6,7 @@ use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\ServiceLocatorAwareInterface; -class Comment extends AbstractHelper implements ServiceLocatorAwareInterface +class Comment extends AbstractHelper implements ServiceLocatorAwareInterface { private $serviceLocator; diff --git a/tests/RbCommentTest/Controller/CommentControllerTest.php b/tests/RbCommentTest/Controller/CommentControllerTest.php index a95256a..64b05f1 100644 --- a/tests/RbCommentTest/Controller/CommentControllerTest.php +++ b/tests/RbCommentTest/Controller/CommentControllerTest.php @@ -14,8 +14,12 @@ class CommentControllerTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->serviceLocatorMock = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface', - array('get', 'has'), array(), 'ServiceLocatorInterface'); + $this->serviceLocatorMock = $this->getMock( + 'Zend\ServiceManager\ServiceLocatorInterface', + array('get', 'has'), + array(), + 'ServiceLocatorInterface' + ); // Global values $_SERVER['HTTP_USER_AGENT'] = 'RbComment Testing Suite'; @@ -36,8 +40,13 @@ public function testIsSpam($comment, $isSpam) ), ); - $akismetServiceMock = $this->getMock('ZendService\Akismet\Akismet', - array('isSpam'), array(), '', false); + $akismetServiceMock = $this->getMock( + 'ZendService\Akismet\Akismet', + array('isSpam'), + array(), + '', + false + ); $akismetServiceMock->expects($this->once()) ->method('isSpam') @@ -87,8 +96,13 @@ public static function isSpamDataProvider() public function testGetCommentTableReturnsAnInstanceOfCommentTable() { - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array(), array(), '', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', + array(), + array(), + '', + false + ); $commentTable = new CommentTable($tableGatewayMock); diff --git a/tests/RbCommentTest/Model/CommentTableTest.php b/tests/RbCommentTest/Model/CommentTableTest.php index 1b8b7e8..c5f1996 100644 --- a/tests/RbCommentTest/Model/CommentTableTest.php +++ b/tests/RbCommentTest/Model/CommentTableTest.php @@ -12,8 +12,9 @@ class CommentTableTest extends PHPUnit_Framework_TestCase { public function testConstructorSetsDependencies() { - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array(), array(), 'TableGateway', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', array(), array(), + 'TableGateway', false); $commentTable = new CommentTable($tableGatewayMock); $reflectedCommentTable = new ReflectionClass($commentTable); @@ -29,8 +30,13 @@ public function testConstructorSetsDependencies() public function testFetchAllReturnsAllComments() { $resultSet = new ResultSet(); - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array('select'), array(), '', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', + array('select'), + array(), + '', + false + ); $tableGatewayMock->expects($this->once()) ->method('select') ->will($this->returnValue($resultSet)); @@ -43,8 +49,14 @@ public function testFetchAllReturnsAllComments() public function testFetchAllForThreadReturnsAllTheCommentsInThread() { $resultSet = new ResultSet(); - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array('selectWith'), array(), '', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', + array('selectWith'), + array(), + '', + false + ); + $tableGatewayMock->expects($this->once()) ->method('selectWith') ->will($this->returnValue($resultSet)); @@ -72,8 +84,14 @@ public function testCanRetrieveACommentByItsId() $resultSet->setArrayObjectPrototype(new Comment()); $resultSet->initialize(array($comment)); - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array('select'), array(), '', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', + array('select'), + array(), + '', + false + ); + $tableGatewayMock->expects($this->once()) ->method('select') ->with(array('id' => 12345)) @@ -99,8 +117,14 @@ public function testSaveCommentWillInsertNewCommentIfDoesNotAlreadyHaveAnId() $comment->exchangeArray($commentData); - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array('insert'), array(), '', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', + array('insert'), + array(), + '', + false + ); + $tableGatewayMock->expects($this->once()) ->method('insert') ->with($commentData); @@ -129,8 +153,14 @@ public function testSaveCommentWillUpdateExistingCommentIfItAlreadyHasAnId() $resultSet->setArrayObjectPrototype(new Comment()); $resultSet->initialize(array($comment)); - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array('select', 'update'), array(), '', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', + array('select', 'update'), + array(), + '', + false + ); + $tableGatewayMock->expects($this->once()) ->method('select') ->with(array('id' => 12345)) @@ -153,8 +183,14 @@ public function testSaveCommentWillUpdateExistingCommentIfItAlreadyHasAnId() public function testCanDeleteACommentByItsId() { - $tableGatewayMock = $this->getMock('Zend\Db\TableGateway\TableGateway', - array('delete'), array(), '', false); + $tableGatewayMock = $this->getMock( + 'Zend\Db\TableGateway\TableGateway', + array('delete'), + array(), + '', + false + ); + $tableGatewayMock->expects($this->once()) ->method('delete') ->with(array('id' => 12345)); diff --git a/tests/RbCommentTest/Mvc/Controller/Plugin/MailerTest.php b/tests/RbCommentTest/Mvc/Controller/Plugin/MailerTest.php index 990b51d..69f5271 100644 --- a/tests/RbCommentTest/Mvc/Controller/Plugin/MailerTest.php +++ b/tests/RbCommentTest/Mvc/Controller/Plugin/MailerTest.php @@ -9,8 +9,12 @@ class MailerTest extends PHPUnit_Framework_TestCase { public function testSetAndGetServiceLocator() { - $serviceLocatorMock = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface', - array(), array(), 'ServiceLocatorInterface'); + $serviceLocatorMock = $this->getMock( + 'Zend\ServiceManager\ServiceLocatorInterface', + array(), + array(), + 'ServiceLocatorInterface' + ); $mailer = new Mailer(); $mailer->setServiceLocator($serviceLocatorMock); diff --git a/tests/RbCommentTest/View/Helper/CommentTest.php b/tests/RbCommentTest/View/Helper/CommentTest.php index a6ea6c3..f693f7d 100644 --- a/tests/RbCommentTest/View/Helper/CommentTest.php +++ b/tests/RbCommentTest/View/Helper/CommentTest.php @@ -9,8 +9,12 @@ class CommentTest extends PHPUnit_Framework_TestCase { public function testSetAndGetServiceLocator() { - $serviceLocatorMock = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface', - array(), array(), 'ServiceLocatorInterface'); + $serviceLocatorMock = $this->getMock( + 'Zend\ServiceManager\ServiceLocatorInterface', + array(), + array(), + 'ServiceLocatorInterface' + ); $commentViewHelper = new RbCommentViewHelper(); $commentViewHelper->setServiceLocator($serviceLocatorMock);