Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmarsal committed Jan 3, 2014
1 parent 367109a commit 0a55f1c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/RbComment/Controller/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/RbComment/View/Helper/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
26 changes: 20 additions & 6 deletions tests/RbCommentTest/Controller/CommentControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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')
Expand Down Expand Up @@ -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);

Expand Down
64 changes: 50 additions & 14 deletions tests/RbCommentTest/Model/CommentTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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))
Expand All @@ -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);
Expand Down Expand Up @@ -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))
Expand All @@ -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));
Expand Down
8 changes: 6 additions & 2 deletions tests/RbCommentTest/Mvc/Controller/Plugin/MailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions tests/RbCommentTest/View/Helper/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0a55f1c

Please sign in to comment.